Jump to content

mysql_fetch_array problems


eon201

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/78052-mysql_fetch_array-problems/
Share on other sites

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]); 

lol. :D

 

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.