thefollower Posted December 10, 2007 Share Posted December 10, 2007 Can any see where i have gone wrong with my query.. it gives me a syntax error... can't see where the syntax is though ... $InsetLog = mysql_query("INSERT INTO userlogs (UserID, Log, Date) Values('{$_SESSION['Current_User']}', '$Username failed to logged in.', '$Date'") or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
beansandsausages Posted December 10, 2007 Share Posted December 10, 2007 try : $InsetLog = mysql_query("INSERT INTO userlogs ('UserID', 'Log', 'Date') Values('{$_SESSION['Current_User']}', '$Username failed to logged in.', '$Date'") or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted December 10, 2007 Share Posted December 10, 2007 $InsetLog = mysql_query("INSERT INTO userlogs (UserID, Log, `Date`) VALUES ('{$_SESSION['Current_User']}', '$Username failed to logged in.', '$Date')") or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
trq Posted December 10, 2007 Share Posted December 10, 2007 You need to surround the Date field in `backticks` and insure there are spaces around the word VALUES. $InsetLog = mysql_query("INSERT INTO userlogs (UserID, Log, `Date`) VALUES ('{$_SESSION['Current_User']}', '$Username failed to logged in.', '$Date'") or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted December 10, 2007 Share Posted December 10, 2007 If you were to post the error message you got, it would help find the problem rather than using up 20 guesses. BTW: date is a data type, not a reserved keyword. It can be a table or column name without any special handling. Quote Link to comment Share on other sites More sharing options...
thefollower Posted December 10, 2007 Author Share Posted December 10, 2007 $InsetLog = mysql_query("INSERT INTO userlogs (UserID, Log, `Date`) VALUES ('{$_SESSION['Current_User']}', '$Username failed to logged in.', '$Date'") or die(mysql_error()); Gives: 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 '' at line 1 Would you like to see the whole script? Quote Link to comment Share on other sites More sharing options...
trq Posted December 10, 2007 Share Posted December 10, 2007 It would appear that either $_SESSION['Current_User'] or $Date are empty. Make sure they are not. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted December 10, 2007 Share Posted December 10, 2007 The syntax in the query is still wrong. You have the end quote in the wrong place, and also missing a parenthesis. Try my code and see if it works. Quote Link to comment Share on other sites More sharing options...
thefollower Posted December 10, 2007 Author Share Posted December 10, 2007 Oh good spot. Thanks ! Working now 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.