Jump to content

insert time


conan318

Recommended Posts

hi im trying to insert the username and time into the online table the trouble is nothing is getting inserted into the table no errors

have echoed both variables to check they contain the right information and they do.

$time=time();
echo $time;
echo $myusername;

$insert_user=mysql_query("INSERT INTO cvisinko_db.online (username,time,) VALUES ('$myusername','$time')") ;

 

then the plan is display a basic online list

haven't been able to test this as nothing is getting inserted into the online table

$data = mysql_query("SELECT count(*) from cvisinko_db.online WHERE `time` >= DATE_SUB(NOW(), INTERVAL 30 minute);") or die(mysql_error());

 

 

 

Link to comment
Share on other sites

Yes. You want to echo mysql_error() right after the query.

 

A smart way to do it would be (shouldn't be used in production, just for testing)

 

if( mysql_query($query) == FALSE ) echo mysql_error();

 

Next time, try before you ask :D

Link to comment
Share on other sites

thats a neat little trick. but the result was the Query was empty which explains why nothing is being inserted into the database. but does  not explain why my query is empty

$time=time();
echo $time; // echo fine
echo $myusername; // fine

$insert_user=mysql_query("INSERT INTO cvisinko_db.online (username,time,) VALUES ('$myusername','$time')") ;
if( mysql_query($insert_user) == FALSE ) echo mysql_error();

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.