topflight Posted June 18, 2009 Share Posted June 18, 2009 I am trying to insert something to the database and I getting the falling error. Stored in: screenshots/fs2004-2009-jun-17-019.jpgYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'show) VALUES ('2001', 'fs2004-2009-jun-17-019.jpg', '67.169.186.234', '06' at line 2 This is the insert code <?php include'db.php'; $name = $_POST['name']; $login = $_POST['login']; $ip = $_POST['ip']; $dscp = $_POST['descp']; $info = $_FILES["file"]["name"]; $link = "$info"; $fdate = $_POST['udate']; $show = $_POST['public']; $insert = mysql_query ("INSERT INTO `screenshots`(login,link,ip,date,name,decp,show) VALUES ('$login','$link','$ip','$fdate','$name','$dscp','$show') ") or die(mysql_error()); ?> Thanks in advanced. Quote Link to comment https://forums.phpfreaks.com/topic/162684-solved-insert-help/ Share on other sites More sharing options...
MadTechie Posted June 18, 2009 Share Posted June 18, 2009 show is a reserved word change the field name or back tick it ie $insert = mysql_query ("INSERT INTO `screenshots`(login,link,ip,date,name,decp,`show`) VALUES ('$login','$link','$ip','$fdate','$name','$dscp','$show') ") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/162684-solved-insert-help/#findComment-858545 Share on other sites More sharing options...
topflight Posted June 18, 2009 Author Share Posted June 18, 2009 I am confused Quote Link to comment https://forums.phpfreaks.com/topic/162684-solved-insert-help/#findComment-858546 Share on other sites More sharing options...
MadTechie Posted June 18, 2009 Share Posted June 18, 2009 You have a field in the screenshots table called show, correct ? Well Show is a MySQL reserved word (meaning it has a special meaning) So you can't use it the way you are trying to use it. so to tell MySQL its a field you add the back ticks ` think if it this way, just say i have a field called SELECT and i ENTER SELECT SELECT from table MySQL would be quite confused so i would need to do this SELECT `SELECT` from table So either rename the field you have called "show" to "ShowIT" (for example) or change the query to the one in my last post Quote Link to comment https://forums.phpfreaks.com/topic/162684-solved-insert-help/#findComment-858550 Share on other sites More sharing options...
topflight Posted June 18, 2009 Author Share Posted June 18, 2009 oooo ok thanks fixed Quote Link to comment https://forums.phpfreaks.com/topic/162684-solved-insert-help/#findComment-858552 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.