dhcrusoe Posted January 7, 2009 Share Posted January 7, 2009 Hey guys, What on earth is going on here? I'm getting a MySQL insert error, even though this code worked earlier... I'm thinking I have an extra character in there somewhere, but for the life of me, can't see it ??? foreach ($inf as $key => $value) { if (!mysql_query("INSERT INTO data (votes,date,prog,progname) VALUES ('".$inf[$key]['votes']."',".$global_date.",'".$key."','".$inf[$key]['progname']."')")) { trigger_error("MySQL Error occured : ".mysql_error($con), E_USER_WARNING ); } Thanks for your helpful (eyes!) --Dave Link to comment https://forums.phpfreaks.com/topic/139838-something-simple-wrong-in-this-sql-insert-query/ Share on other sites More sharing options...
gevans Posted January 7, 2009 Share Posted January 7, 2009 I'm guessing you just missed it out, but the last curly bracket is missing. Also is global_date and integer? And can you post the exact error you get Link to comment https://forums.phpfreaks.com/topic/139838-something-simple-wrong-in-this-sql-insert-query/#findComment-731543 Share on other sites More sharing options...
dhcrusoe Posted January 7, 2009 Author Share Posted January 7, 2009 Yep... sorry, there is another } down in the code, but that's not the issue here (see error, pasted) oh! pasting it, I see -- time has no ' at the end, I think Error Level : 512 | Desc : MySQL Error occured : 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 '06:56:16,'0','Vegan school lunch options')' at line 1 [ /home/plmlorg/public_html/ChangeAnalytics2/test2.php=>90] I'm guessing you just missed it out, but the last curly bracket is missing. Also is global_date and integer? And can you post the exact error you get Link to comment https://forums.phpfreaks.com/topic/139838-something-simple-wrong-in-this-sql-insert-query/#findComment-731553 Share on other sites More sharing options...
gevans Posted January 7, 2009 Share Posted January 7, 2009 Yes you need to wrap all strings mysql_query("INSERT INTO data (votes,date,prog,progname) VALUES ('".$inf[$key]['votes']."','".$global_date."','".$key."','".$inf[$key]['progname']."')") Link to comment https://forums.phpfreaks.com/topic/139838-something-simple-wrong-in-this-sql-insert-query/#findComment-731564 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.