conan318 Posted September 7, 2011 Share Posted September 7, 2011 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()); Quote Link to comment https://forums.phpfreaks.com/topic/246671-insert-time/ Share on other sites More sharing options...
Pikachu2000 Posted September 7, 2011 Share Posted September 7, 2011 Is the time field a DATETIME data type or . . . ? Quote Link to comment https://forums.phpfreaks.com/topic/246671-insert-time/#findComment-1266630 Share on other sites More sharing options...
conan318 Posted September 7, 2011 Author Share Posted September 7, 2011 using type time. Quote Link to comment https://forums.phpfreaks.com/topic/246671-insert-time/#findComment-1266632 Share on other sites More sharing options...
xyph Posted September 7, 2011 Share Posted September 7, 2011 Did you check mysql_error() ? It will return any errors encountered with the last MySQL query. Quote Link to comment https://forums.phpfreaks.com/topic/246671-insert-time/#findComment-1266637 Share on other sites More sharing options...
conan318 Posted September 7, 2011 Author Share Posted September 7, 2011 Did you check mysql_error() ? It will return any errors encountered with the last MySQL query. no i havent not sure how do that. do i just echo mysql_error()? Quote Link to comment https://forums.phpfreaks.com/topic/246671-insert-time/#findComment-1266640 Share on other sites More sharing options...
xyph Posted September 7, 2011 Share Posted September 7, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/246671-insert-time/#findComment-1266643 Share on other sites More sharing options...
conan318 Posted September 8, 2011 Author Share Posted September 8, 2011 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(); Quote Link to comment https://forums.phpfreaks.com/topic/246671-insert-time/#findComment-1266646 Share on other sites More sharing options...
xyph Posted September 8, 2011 Share Posted September 8, 2011 $insert_user=mysql_query("INSERT INTO cvisinko_db.online (username,time,) VALUES ('$myusername','$time')") ; if( mysql_query($insert_user) You're querying a query :/ Quote Link to comment https://forums.phpfreaks.com/topic/246671-insert-time/#findComment-1266649 Share on other sites More sharing options...
conan318 Posted September 8, 2011 Author Share Posted September 8, 2011 topic solved i had an extra , after time. $insert_user=mysql_query("INSERT INTO cvisinko_db.online (username,time) VALUES ('$myusername','$time')") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/246671-insert-time/#findComment-1266654 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.