Dirty-Rockstar Posted August 16, 2007 Share Posted August 16, 2007 test1.php <?php include('sidebar.php'); print " <center><table> <tr> <td><form action=test.php method=post>Item name:</td> <td><input type=text name=itemname></td> </tr> <tr> <td>description: </td> <td><input type=text name=description></td> </tr> </table> <input type=submit value=Submit></form>"; print "</body></html>"; ?> test.php <? include('sidebar.php'); print "$_POST[itemname] <br /> $_POST[description]<br />"; $iteminsert1="INSERT INTO items (itemname, description) VALUES ( '{$_POST['itemname']}','{$_POST['description']}'"; $iteminsert2=mysql_query($iteminsert1) or die(mysql_error()); if ($iteminsert2) { print "Inserted"; }else{ Print "didnt work"; }; ?> Result: item weeeeeeeee You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 table fields: itemID (bigint20) (auto increment) itemname (text) description (text) I cant figure it out--thanks Link to comment https://forums.phpfreaks.com/topic/65329-solved-cannot-insert-into-db-getting-mysql-error/ Share on other sites More sharing options...
lemmin Posted August 16, 2007 Share Posted August 16, 2007 You aren't closing the values() function. You need: "..VALUES ( '{$_POST['itemname']}','{$_POST['description']}')"; Link to comment https://forums.phpfreaks.com/topic/65329-solved-cannot-insert-into-db-getting-mysql-error/#findComment-326257 Share on other sites More sharing options...
Dirty-Rockstar Posted August 16, 2007 Author Share Posted August 16, 2007 If i told you i worked for about an hour on that thing you would probably spit your coffee on your monitor issue resolved Link to comment https://forums.phpfreaks.com/topic/65329-solved-cannot-insert-into-db-getting-mysql-error/#findComment-326264 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.