PHP DATABSE CONNECTION TEST CODE

<?php

 

# Fill our vars and run on cli

 

# $ php -f db-connect-test.php

 

 

 

$dbname = 'name';

 

$dbuser = 'user';

 

$dbpass = 'pass';

 

$dbhost = 'host';

 

 

 

$connect = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'");

 

mysql_select_db($dbname) or die("Could not open the db '$dbname'");

 

 

 

$test_query = "SHOW TABLES FROM $dbname";

 

$result = mysql_query($test_query);

 

 

 

$tblCnt = 0;

 

while($tbl = mysql_fetch_array($result)) {

 

  $tblCnt++;

 

  #echo $tbl[0]."<br />\n";

 

}

 

 

 

if (!$tblCnt) {

 

  echo "There are no tables<br />\n";

 

} else {

 

  echo "There are $tblCnt tables<br />\n";

 

}

  • 0 کاربر این را مفید یافتند
آیا این پاسخ به شما کمک کرد؟

Related Articles

SERVER GROUP POLICY SEARCH SITE

Great place , Thanks to Stefanus for supplying this link.

ADDITIONAL EMAIL DOMAINS IN SMALL BUSINESS SERVER 2011 EXCHANGE

Great article, easy to follow and Accurate.. All thanks to Robert Pearman for this excellent...

SIMPLE REDIRECT SCRIPT

Place this script in the page you wish to redirect :-     <meta http-equiv="refresh"...

ENGIN VOICEMAIL DELETION / REMOVAL PROCEDURE

Clear your Engin Voice-mail or Fax-mail box by Admin on September 6th, 2011 If left...

Engin Voip Phone Instruction / Features PDF

http://www.melbournemobiles.com.au/files/features%20user%20guide.pdf