ifis Posted January 6, 2008 Share Posted January 6, 2008 I am trying to save information from a form in an 'Endorsementlog' table. The only problem is that only the first option of "lic" will write to the database. All the other options still work and set "lic" to whatever it is supposed to be, but will not write to the table. echo "<form id='form1' name='form1' method='POST' action='endorsementform.php'> <p> <input name='firstName' type='hidden' id='firstName' value='$row[firstName]' /> <input name='lastName' type='hidden' id='lastName' value='$row[lastName]' /> </p> <p>Endorsement:<br /> <select name='lic' id='lic'> <option>Pre-Solo Aeronautical Knowledge</option> <option>Pre-Solo Flight Training</option> <?php $today=date("Y/m/d"); $make=$_POST['make']; $lic = $_POST['lic']; $student=$_POST['student']; $sex = $_POST['sex']; $CFI=$_POST['CFI']; $expireip=$_POST['expireip']; $firstName=$_POST['firstName']; $lastName=$_POST['lastName']; include("endorsementlog.inc"); // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); //write to instructor log mysql_query("INSERT INTO $tbl_name (Username, Date, Student, Endorsement) VALUES ('{$_SESSION['myusername']}','$today', '$student','$lic')"); What am I doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/84684-solved-problems-writing-to-mysql-database/ Share on other sites More sharing options...
papaface Posted January 6, 2008 Share Posted January 6, 2008 Change it to: <?php $today=date("Y/m/d"); $make=$_POST['make']; $lic = $_POST['lic']; $student=$_POST['student']; $sex = $_POST['sex']; $CFI=$_POST['CFI']; $expireip=$_POST['expireip']; $firstName=$_POST['firstName']; $lastName=$_POST['lastName']; include("endorsementlog.inc"); // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); //write to instructor log mysql_query("INSERT INTO $tbl_name (Username, Date, Student, Endorsement) VALUES ('{$_SESSION['myusername']}','$today', '$student','$lic')") or die (mysql_error()); and tell us the error it produces. Quote Link to comment https://forums.phpfreaks.com/topic/84684-solved-problems-writing-to-mysql-database/#findComment-431574 Share on other sites More sharing options...
ifis Posted January 6, 2008 Author Share Posted January 6, 2008 That was stupid! I was testing the database, and ended up having the table keys be the same, I change some of the inputs and it works. learned my lesson about including error reporting, thanks for all the help! Quote Link to comment https://forums.phpfreaks.com/topic/84684-solved-problems-writing-to-mysql-database/#findComment-431580 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.