dgulliver Posted April 20, 2009 Share Posted April 20, 2009 Hi I'm new to php. At present I have some Information on a home page with internal (including a link to my forums) and external links. I would also like to show the status of the mySQL database status. I.e. if the Database is running or not. If not I'd like a message to be shown (not a popup). Examples I've seen include having the database details but obviously I don’t want to expose these details to robots etc. Any help appreciated Regards Darren Link to comment https://forums.phpfreaks.com/topic/154842-solved-displaying-the-status-of-a-database/ Share on other sites More sharing options...
Yesideez Posted April 20, 2009 Share Posted April 20, 2009 Welcome! The best way I'd do this is to try and establish a connection but disable the error reporting and handle any failure myself. if (@mysql_connect($server,$user,$pass)) { $dbisonline=true; } else { $dbisonline=false; } The @ in front of mysql_connect() prevents any error messages being sent to the browser. Link to comment https://forums.phpfreaks.com/topic/154842-solved-displaying-the-status-of-a-database/#findComment-814364 Share on other sites More sharing options...
dgulliver Posted April 20, 2009 Author Share Posted April 20, 2009 Wow, thanks for the quick response Yesideez Will give it ago. I assume I can hide my DB details from a robot or human. Regards, Darren Link to comment https://forums.phpfreaks.com/topic/154842-solved-displaying-the-status-of-a-database/#findComment-814373 Share on other sites More sharing options...
Yesideez Posted April 20, 2009 Share Posted April 20, 2009 Yes because those details will be inside a PHP file which can't be downloaded by a user unless they have FTP access. A browser accessing a PHP file will only view what they generate. If it doesn't output anything to the browser then all they'll get back is an empty page. Link to comment https://forums.phpfreaks.com/topic/154842-solved-displaying-the-status-of-a-database/#findComment-814375 Share on other sites More sharing options...
dgulliver Posted April 20, 2009 Author Share Posted April 20, 2009 again thanks for the quick response - impressed Thanks for your answers. Will post back when I have done this. Thanks Darren Link to comment https://forums.phpfreaks.com/topic/154842-solved-displaying-the-status-of-a-database/#findComment-814378 Share on other sites More sharing options...
Yesideez Posted April 20, 2009 Share Posted April 20, 2009 btw, a bot accessing a PHP file acts the same as a human - it gets back only what the PHP file outputs so the same result applies as in my previous post - the bot will get back an empty file if nothing is being output. Link to comment https://forums.phpfreaks.com/topic/154842-solved-displaying-the-status-of-a-database/#findComment-814380 Share on other sites More sharing options...
dgulliver Posted April 20, 2009 Author Share Posted April 20, 2009 gotta bud Link to comment https://forums.phpfreaks.com/topic/154842-solved-displaying-the-status-of-a-database/#findComment-814382 Share on other sites More sharing options...
dgulliver Posted April 20, 2009 Author Share Posted April 20, 2009 ok, Still cannot graasp it maybe is bcause I have been coding all day in VB and I'm just missing something doing the example with my page as index.php I can do with no problem. however I need my html page to execute the php and show the status of the forum. Have a look at www.guild-madness.co.uk on the right side there is a forum status bit. Here is where I want to show Forums: Running or Forums: Down ~ Please try again later. If I understand correctly I need to show the index.php which has my html and then when I need to execute the php just put <?php do something ?> Link to comment https://forums.phpfreaks.com/topic/154842-solved-displaying-the-status-of-a-database/#findComment-815074 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.