UnitedForums - UK Web Hosting Forum UnitedHosting Community Hosting Forums
Network and Server StatusCustomer SupportUK Web Hosting
UnitedHostingUnitedHosting Sitemap UK Hosting ForumUK Web HostingWeb Hosting ForumsUK Reseller HostingWeb Host CommunityUK Managed Dedicated ServersHosting Help and SupportUK Domain Name Registration

Go Back   UnitedForums.co.uk > UnitedHosting Community > Website Development & Scripting

Reply
 
Thread Tools Rate Thread Display Modes
Old 26th April 2003, 12:57 PM   #1 (permalink)
5Sasha5
Registered User
 
Join Date: Apr 2003
Location: Ireland
Posts: 3
PHP/MySQL: Last Updated Date

Hi everyone,
I'm having a problem with a very simple script I'm trying to run.
I want to display the date one of the tables in my MySQL database was last updated.
This is the coding I'm using (obviously with my real username and password instead of the ****):

Code:
<?
$database="eliza-d_com";
$user="******";
$pass="******";
mysql_connect(localhost,$user,$pass);
mysql_select_db($database) or die( "Unable to select database");

$info = mysql_fetch_array(mysql_query("show table status from eliza-d_com like 'missy'"));
echo $info["Update_time"];
?>
But no matter what I try, I get the following error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/virtual/site61/fst/var/www/html/datetest.php on line 21

I have tried several variations on this little script, and none work. I can connect to the database just fine, other queries I put in to test that, worked fine. If I leave off the fetch_array, the script executes fine too, with no errors. It just doesn’t display anything because I can’t seem to access the results of the query. You can see it in action here: http://eliza-d.com/datetest.php

I have googled this for like 3 days now, but to no avail. All resources I found that mention how to do this, use the code I’m using. Even the PHP and MySQL Manuals instruct to do it this way. I have no idea what I’m doing wrong.

Any help with this would be very much appreciated!
__________________
~ Sasha
5Sasha5 is offline   Reply With Quote
Old 26th April 2003, 03:00 PM   #2 (permalink)
ec8or
Registered User
 
Join Date: Apr 2003
Posts: 39
Re:PHP/MySQL: Last Updated Date

I think the problem is with your database name containing a hyphen, try using backticks around it instead, like this:

SHOW TABLE STATUS FROM `eliza-d_com` LIKE 'missy'

Peace
Nisse
ec8or is offline   Reply With Quote
Old 26th April 2003, 03:03 PM   #3 (permalink)
Euge
Registered User
 
Euge's Avatar
 
Join Date: Feb 2003
Location: Lost in confusion
Posts: 710
Re:PHP/MySQL: Last Updated Date

You can also report the error message by checking the query result:

Code:
$result = mysql_query("show table status from eliza-d_com like 'missy'");
if (!$result) {
    echo mysql_error();
    exit();
}
$info = mysql_fetch_array($result);
echo $info["Update_time"];
Euge is offline   Reply With Quote
Old 26th April 2003, 04:28 PM   #4 (permalink)
5Sasha5
Registered User
 
Join Date: Apr 2003
Location: Ireland
Posts: 3
Re:PHP/MySQL: Last Updated Date

[quote author=ec8or link=board=7;threadid=833;start=0#msg5242 date=1051369226]
I think the problem is with your database name containing a hyphen, try using backticks around it instead, like this:

SHOW TABLE STATUS FROM `eliza-d_com` LIKE 'missy'
[/quote]

That was it! I changed it and now it works like a charm. Thanks sooo much!!!!
__________________
~ Sasha
5Sasha5 is offline   Reply With Quote
Old 26th April 2003, 04:33 PM   #5 (permalink)
UH-Matt
Administrator
 
UH-Matt's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 8,663
Re:PHP/MySQL: Last Updated Date

woo!
__________________
.
Matt
UnitedHosting Staff

For official support please use our helpdesk at UnitedSupport.co.uk

UnitedHosting proudly hosting more than 20,000 sites since 1998.
UH-Matt is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 08:02 AM.

UK Web Hosting  |  UK Reseller Hosting  |  UK Dedicated Servers UnitedHosting  |  UnitedSupport  |  SEO by vBSEO 3.0.0
Copyright © 1998-2009 United Communications Limited. All Rights Reserved. Registered in England and Wales 3651923 - VAT Reg No. 737662309