Jump to content

Need Help INSERTing Time in to mySQL.


wezly

Recommended Posts

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!?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.