eon201 Posted November 20, 2007 Share Posted November 20, 2007 Hi im trying to access the 'update' time from my database by using the below code. $result = mysql_query("SHOW TABLE STATUS FROM logtable;"); while($array = mysql_fetch_array($result)) { print_r($array[update_time]); // Will print information about each table stored in database The only problem is I get this error. What am I doing wrong?? 'Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in...' Please help, been stick on this one for a while now! Many thanks Eon201 ??? Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 20, 2007 Share Posted November 20, 2007 i think $result = mysql_query("SHOW TABLE STATUS FROM logtable;"); should be $result = mysql_query("SHOW TABLE STATUS FROM logtable"); there is a semi-colin in the statement Quote Link to comment Share on other sites More sharing options...
pranav_kavi Posted November 20, 2007 Share Posted November 20, 2007 $result = mysql_query("SHOW TABLE STATUS FROM logtable;"); while($array = mysql_fetch_array($result,MYSQL_ASSOC)) { print_r($array[update_time]); // Will print information about each table stored in database } Quote Link to comment Share on other sites More sharing options...
aschk Posted November 20, 2007 Share Posted November 20, 2007 Run that SQL through your command line as the user you are using in PHP. I bet you get an error code coming up. Quote Link to comment Share on other sites More sharing options...
eon201 Posted November 20, 2007 Author Share Posted November 20, 2007 Ok. So im getting the same error still if I use either rajivgonsalves, or pranav_kavi's examples. Im not quite sure what you mean aschk?? Can anyone see what is happening here, or have doen the same thign before?? Thanks. Eon201 Quote Link to comment Share on other sites More sharing options...
pranav_kavi Posted November 20, 2007 Share Posted November 20, 2007 try running the sql statement SHOW TABLE STATUS FROM logtable; in sql server directly rather than thru php.Ther may b some error bcos of wich ur result set is not getting populated. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 20, 2007 Share Posted November 20, 2007 please use the following code to see what the error is $result = mysql_query("SHOW TABLE STATUS FROM logtable") or die("there was an error ".mysql_error()); while($array = mysql_fetch_array($result)) { print_r($array[update_time]); Quote Link to comment Share on other sites More sharing options...
eon201 Posted November 20, 2007 Author Share Posted November 20, 2007 lol. I made a stupid mistake. I had the wrong database name! idiot! so the coe is now like so... $result = mysql_query("SHOW TABLE STATUS FROM pc-monitor") or die("there was an error ".mysql_error()); while($array = mysql_fetch_array($result)) { print_r($array[update_time]); } But the error now says 'there was an error 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 '-monitor' at line 1' I believe the problem now lie's in the '-' between pc and monitor. Is the code misenterpreting this? Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 20, 2007 Share Posted November 20, 2007 this should work mysql_query("SHOW TABLE STATUS FROM `pc-monitor`") or die("there was an error ".mysql_error()); Quote Link to comment Share on other sites More sharing options...
eon201 Posted November 20, 2007 Author Share Posted November 20, 2007 Ok that didnt bring up an error. But neither did they display any output?? Quote Link to comment 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.