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

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)

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.