182x Posted July 18, 2007 Share Posted July 18, 2007 Hey guys, Just wondering what is wrong with the following syntax, I was also wondering id there a way to split the insert statement so it can appear over multiple lines? Thanks $st=mysql_fetch_array($query2) $sto="INSERT INTO em VALUES ('','$st['1]','$st['2']','$st['2']','$st['2']','$st['2']','$st['2']','$st['2']','$st['2']')"; error: Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\a\t\te.php on line 55 Link to comment https://forums.phpfreaks.com/topic/60593-syntax-error/ Share on other sites More sharing options...
akitchin Posted July 18, 2007 Share Posted July 18, 2007 when incorporating array items into a string to be interpolated, you should generally put curly braces around the array item: $sto="INSERT INTO em VALUES ('','{$st['1']}','{$st['2']}','{$st['2']}','{$st['2']}','{$st['2']}','{$st['2']}','{$st['2']}','{$st['2']}')"; you also forgot a closing single quote on $st['1']. Link to comment https://forums.phpfreaks.com/topic/60593-syntax-error/#findComment-301428 Share on other sites More sharing options...
trq Posted July 18, 2007 Share Posted July 18, 2007 Also... numeric indexes should not be surrounded in quotes. $sto="INSERT INTO em VALUES ('','{$st[1]}','{$st[2]}','{$st[2]}','{$st[2]}','{$st[2]}','{$st[2]}','{$st[2]}','{$st[2]}')"; Link to comment https://forums.phpfreaks.com/topic/60593-syntax-error/#findComment-301444 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.