Aqua Posted January 30, 2008 Posted January 30, 2008 It seems i can run the following query on mySQL but i am struggling to get it to work with the PHP. I am not recieving any error message as such, but my results = 'Resource id #4' $TimeDiff = "SELECT TIMEDIFF('2007-11-17 17:10:19','2007-11-17 17:07:05')"; $DownTime = mysql_query($TimeDiff) or die (mysql_error()); I think I need a mysql_fetch, but I am not sure what to use since this query is not coming from a table, any help on this guys. Maybe some other function could help. For example list() , would work in theory. Well i hope you guys can help. Thanks in advance, ¬LK Quote
Floydian Posted February 8, 2008 Posted February 8, 2008 Re: Mysql/PHP problem $TimeDiff = "SELECT TIMEDIFF('2007-11-17 17:10:19','2007-11-17 17:07:05')"; $DownTime = mysql_query($TimeDiff) or die (mysql_error()); If you take that, and then do: echo $DownTime; you are echoing a memory resource locator. In other words, that variable simply holds the "directions" to a place in memory. so, you would need to do msyql_fetch_array or mysql_fetch_row which ever one you choose does not matter, especially if you use list, which I highly recommend in most situations. list($mytime) = mysql_fetch_array($DownTime); echo $mytime; // and you're get the results you expect. Quote
Aqua Posted February 10, 2008 Author Posted February 10, 2008 Re: Mysql/PHP problem Well thank you for re-assuring me that list() function works good for this exact situation. $query = "SELECT TIMEDIFF('2007-11-17 17:10:19','2007-11-17 17:07:05')"; $results = mysql_query($query); list($timediff) = mysql_fetch_array($results); echo $timediff; // 00:03:14 Thank you Floydian... :) Quote
Floydian Posted February 11, 2008 Posted February 11, 2008 Re: Mysql/PHP problem You're welcome! Thanks for letting me know it worked. Quote
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.