0

First off, system specs : MAC OSX, PHP 5 and MySQL 5.1.51

Trying something very simple and for the life of me it just won't work...

HTML Form Code: Filename : AG_test_DB.html

<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>AG test</title>
</head>
<body>
<form method="post" action="add.php">
  <input name="fname" type="text">
  <input name="lname" type="text"> 
  <input name="note" type="text"> 
  <input value="Submit" type="submit">
</form>
</body>
</html>

PHP Script : Filename: add.php

<?php
$DBhost = "localhost";
$DBuser = "root";
$DBpass = "xxxxx";
$DBName = "AG_test_DB";
$table = "info";


$fname = $_POST['fname'];
$lname = $_POST['lname'];
$note = $_POST['note'];


echo $_POST['fname'];
echo $_POST['lname'];
echo $_POST['note'];

echo $fname;
echo $lname;
echo $note;

mysql_connect("localhost","root","xxxxx") or die(mysql_error());

mysql_select_db("AG_test_DB") or die(mysql_error());

mysql_query("INSERT INTO info VALUES('$fname','$lname','$note')");
?>

Everything is echoing just fine so I know the formdata is being passed correctly...however, nothing gets written to the db...any input would be appreciated.

- Lou

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by CanadianGSX
0

Try re-writting your query so that it looks something like this:

$insert = mysql_query("INSERT INTO info (field1,field2,field3) VALUES ('$fname','$lname','$note')") or die(mysql_error());

(replacing <field1><field2> etc with the names of the corresponding columns in your database)

Edited by nonshatter: n/a

0

I knew I was overlooking something simple...amazing how when you stare at something for so long you become blind to the small simple things :)

Thanks a bunch for being my fresh pair of eyes!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.