Jump to content

Display last updated date from another server


busnut

Recommended Posts

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.

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.

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?

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

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.

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.