HELLO,
I'm trying to make a input form that uses a couple of list boxes to input data to a database.
I have no problem inserting the info into the database when it is only one list box
but when I put two list boxes in the form.
I am getting an error telling me that "data could not be inserted in database"
here is an example of what I am talking about.
HTML Form (insert.html)
<HTML>
<HEAD><TITLE>INSERT Data via PHP</TITLE></HEAD><BODY>
<FORM action="insert.php" method="post">
First Name: <input type="text" name="fname"><BR>
Last Name: <input type="text" name="lname"><BR>
Credit Card: <select name= "creditcard" size= "1"><option value="VISA" SELECTED>VISA</option> <option value="AMEX">AMEX</option> </select><BR><BR>
<input type="submit" value="Submit to insert.php">
</FORM>
</BODY>
</HTML>
PHP Script (insert.php)
<HTML>
<HEAD><TITLE>INSERT Data via PHP</TITLE></HEAD><BODY>
<?PHP
$connection=mysql_connect("localhost","someUserIDhere","somePasswordHere") or die('Could not connect to the database server');
$db = mysql_select_db("someDatabaseHere", $connection) or die ("Unable to select database.");
$sql = "INSERT INTO user (fname,lname,creditcard) VALUES ('$fname','$lname','$creditcard')";
$sql_result = mysql_query($sql,$connection) or die ('Could not insert data');
echo('Data inserted successfully.');
mysql_close($connection);
?>
</BODY>
</HTML>
this code works perfectly,
but this code doesn't............
<HEAD><TITLE>INSERT Data via PHP</TITLE></HEAD><BODY>
<FORM action="do_testlist.php" method="post">
First Name: <input type="text" name="fname"><BR>
Last Name: <input type="text" name="lname"><BR>
Credit Card: <select name= "creditcard" size= "1"><option value="VISA" SELECTED>VISA</option> <option value="AMEX">AMEX</option><option value="MAS">MASTERCARD</option><option value="DIS">DISCOVERCARD</option> </select><BR>
ENTERTAINMENT: <select name= "ent" size= "1"><option value="MOV" SELECTED>movie</option> <option value="THEA">THEATHER</option><option value="COMEDY">COMEDY</option><option value="DINNER">DINNER</option> </select><br><br>
<input type="submit" value="Submit to insert.php">
</FORM>
</BODY>
</HTML>
<HTML>
<HEAD><TITLE>INSERT Data via PHP</TITLE></HEAD><BODY>
<?PHP
$connection=mysql_connect("("localhost","someUserIDhere","somePasswordHere") or die('Could not connect to the database server');
$db = mysql_select_db("someDatabaseHere", $connection) or die ("Unable to select database.");
$sql = "INSERT INTO user (fname,lname,creditcard,ent) VALUES ('$fname','$lname','$creditcard',$ent)";
$sql_result = mysql_query($sql,$connection) or die ('Could not insert data');
echo('Data inserted successfully.');
mysql_close($connection);
?>
</BODY>
</HTML>
I create a new field in the database user
called ent and create the varible $ent.
still not working.
any ideas.