Username: Posted March 4, 2011 Share Posted March 4, 2011 I can't seem to find anything wrong with it, but it keeps giving me this error: 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 'desc,img,vid) values('1','3','img/1299254331.PNG','2')' at line 1 My query: include('includes/connect.php'); mysql_query("INSERT INTO ".$c[1]." (seed,desc,img,vid) values('$seed','$desc','$final','$vid')") or die(mysql_error()); EDIT: Nevermind, -apparently- you can't have a row called desc, or it thinks it means descending sort. Link to comment https://forums.phpfreaks.com/topic/229587-whats-wrong-with-my-sql-query/ Share on other sites More sharing options...
Maq Posted March 4, 2011 Share Posted March 4, 2011 Yep, check out: http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html Link to comment https://forums.phpfreaks.com/topic/229587-whats-wrong-with-my-sql-query/#findComment-1182847 Share on other sites More sharing options...
Muddy_Funster Posted March 4, 2011 Share Posted March 4, 2011 that's not the best practice, you should assign your SQL string to a variable and then execute the mysql_query() against the variable. try this: $qry ="INSERT INTO ".$c[1]." (seed, desc, img, vid) values('$seed', '$desc', '$final', '$vid')"; mysql_query($qry) or die($qry.'<br>Failed to run due to the following error :<br>'.mysql_error()); and see how you get on. Link to comment https://forums.phpfreaks.com/topic/229587-whats-wrong-with-my-sql-query/#findComment-1182851 Share on other sites More sharing options...
The Little Guy Posted March 5, 2011 Share Posted March 5, 2011 desc is a mysql command you shouldn't use that as a column name. if you do you should put tick marks around it, like so: mysql_query("INSERT INTO ".$c[1]." (seed,`desc`,img,vid) values('$seed','$desc','$final','$vid')") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/229587-whats-wrong-with-my-sql-query/#findComment-1183146 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.