wezly Posted November 1, 2010 Share Posted November 1, 2010 hey, here is the code I am using. mysql_connect("localhost","XXXXXX","XXXXXX") or die("Could not connect."); mysql_select_db("XXXXXX"); $query="SELECT * FROM VIDEO_SESSIONS"; $result=mysql_query($query); while ($db_field = mysql_fetch_assoc($result)) { $timeslider = $db_field['timeslider']; } $message=$_POST['message']; $name=$me['first_name']; if(isset($_POST['submit'])){ if(strlen($message)<1) { print "You did not input a message"; } else if(strlen($name)<1) { print "Please login with Facebook to post a message"; } else { $insertmessage="INSERT INTO CHAT_SESSIONS (user_id,user_message,current_time) VALUES ('$name', '$message', '$timeslider')"; mysql_query($insertmessage); echo mysql_error(); } } ?> I am getting this error everytime I try and INSERT into the database " 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 'current_time) VALUES ('Luke', 'Hello?', '00:23:00')' at line 2 " it works fine without the '$timeslider' which is a time stored on the database in the format 00:00:00 why does it not want to store the time back in a different table.. same format!? Quote Link to comment https://forums.phpfreaks.com/topic/217467-need-help-inserting-time-in-to-mysql/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 1, 2010 Share Posted November 1, 2010 current_time, the point in the query that is being called out in the error message, is a reserved mysql keyword. You either need to rename your column or enclose that in back-ticks `` every time you use it in a query. Quote Link to comment https://forums.phpfreaks.com/topic/217467-need-help-inserting-time-in-to-mysql/#findComment-1129042 Share on other sites More sharing options...
wezly Posted November 1, 2010 Author Share Posted November 1, 2010 Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/217467-need-help-inserting-time-in-to-mysql/#findComment-1129106 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.