thefollower Posted December 11, 2007 Share Posted December 11, 2007 I have an insert query which is inputting a sentence but some of the sentence is created with session carrying a value and i think its what is causing my syntax error with my insert.... <?php $InsetLog = mysql_query("INSERT INTO userlogs (UserID, Log) VALUES ('{$_SESSION['Current_User']}', 'Trained '{$_SESSION['GainedStrength']}' strength giving them $Strength total strength')") or die(mysql_error()); ?> The error I get is: 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 '0.064' strength giving them 6.4285 total strength')' at line 2 Quote Link to comment Share on other sites More sharing options...
revraz Posted December 11, 2007 Share Posted December 11, 2007 Turn those arrays into just a normal variable and it will be easier to insert. Your quotes are messing you up. Quote Link to comment Share on other sites More sharing options...
Psycho Posted December 11, 2007 Share Posted December 11, 2007 Your problem is the single quotes that are around the "'GainedStrength'" value. You have a single quote right before "Trained" which begins the second value, but then there is a second single quote right after that which closes the second value. <?php $query = "INSERT INTO userlogs (UserID, Log) VALUES ('{$_SESSION['Current_User']}', 'Trained {$_SESSION['GainedStrength']} strength giving them $Strength total strength')"; $InsetLog = mysql_query($query) or die(mysql_error()); ?> Quote Link to comment 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.