e1seix Posted November 14, 2009 Share Posted November 14, 2009 Someone help me out here.. why is this generating an error code for ( $i = 1; $i <= 6; $i++ ) { for ( $j = 1; $j <= 5; $j++ ) { mysql_query('INSERT INTO shows ( country, series, show, name ) VALUES ( "se", "'.$j.'", "'.$i.'", "Heat '.$i.'" )') or die(mysql_error()); } } It generates the following: 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 'show, name ) VALUES ( "se", "1", "1", "Heat 1" )' at line 1 Link to comment https://forums.phpfreaks.com/topic/181512-error-not-sure-why-for-loops-and-insert-into/ Share on other sites More sharing options...
JustLikeIcarus Posted November 16, 2009 Share Posted November 16, 2009 "show" is a mysql reserved word. you will need to put backticks around it. I would recommend renaming the column Link to comment https://forums.phpfreaks.com/topic/181512-error-not-sure-why-for-loops-and-insert-into/#findComment-958437 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.