busnut Posted March 5, 2009 Share Posted March 5, 2009 G'day all, once i've finished my new site, i've got a sister website that displays the date the last time the database on my server was updated, and as im going from flatfile to mysql database, I need some code that will look at my servers database and display on the sister website the date the database was last updated. But I will say that currently there are no fields that have a date - so im not sure if that is going to be a problem or not... Here is some code that a friend sent me, but unsure if this is along the right lines as I can't get it to work: <? $database="mydatabase"; $user="myusername"; $pass="mypassword"; 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 'busfleet'")); echo $info["Update_time"]; ?> Any help really appreciated. Link to comment https://forums.phpfreaks.com/topic/148054-display-last-updated-date-from-another-server/ Share on other sites More sharing options...
awpti Posted March 5, 2009 Share Posted March 5, 2009 Close. If you have more than one table in the 'busfleet' database, you need to add a WHERE clause to it. ex; SELECT TABLE STATUS FROM 'database' WHERE Name = 'my_table_name'; That will only return status from one table rather than multiple. Otherwise, that should work fine. Link to comment https://forums.phpfreaks.com/topic/148054-display-last-updated-date-from-another-server/#findComment-777100 Share on other sites More sharing options...
busnut Posted March 5, 2009 Author Share Posted March 5, 2009 Okay, that makes sense, but I still get the same error message: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in blabla/public_html/testdate.php on line 8 Also the other question is, as the other website is hosted on another server, how can it point to my server to display such date? Link to comment https://forums.phpfreaks.com/topic/148054-display-last-updated-date-from-another-server/#findComment-777102 Share on other sites More sharing options...
busnut Posted March 9, 2009 Author Share Posted March 9, 2009 Alrighty, after sitting on this for a couple of days, i've got this to work: <?php include("connectionfile.php"); // Otherwise we connect to our Database mysql_connect("$hostname", "$user", "$pass")or die("cannot connect"); mysql_select_db("$dbase")or die("cannot select DB"); $res = mysql_query("SHOW TABLE STATUS FROM btbuses_businformation LIKE 'busfleet'") ; echo "Last Updated: ". date('D M Y H:i:s', strtotime(mysql_result($res,0,'Update_time'))); ?> Although, i'm still wanting a sister website hosted on a different server to be able to retrieve the last updated date of my database. Is it possible, if so - would greatly appreciate the help, and if not, what other way is there of doing it? Cheers Link to comment https://forums.phpfreaks.com/topic/148054-display-last-updated-date-from-another-server/#findComment-780343 Share on other sites More sharing options...
busnut Posted March 17, 2009 Author Share Posted March 17, 2009 Sorry to shunt this message back to the top also, but is there anybody with any suggestions on how I can have this script hosted on another server (unrelated to my server), to point to my database on my server to get the last updated time? Help is greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/148054-display-last-updated-date-from-another-server/#findComment-786415 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.