This shows you the differences between two versions of the page.
— |
mysql_connection_test_script [2009/06/04 11:07] (current) k2patel created |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ==== Mysql Connection Test script ==== | ||
+ | <code php | mytest.php > | ||
+ | <?php | ||
+ | $db_name = Database Name; | ||
+ | $db_user = Database User; | ||
+ | $db_pass = Database password; | ||
+ | $link = mysql_connect('localhost', $db_user, $db_pass); | ||
+ | if (!$link) { | ||
+ | die('Could not connect: ' . mysql_error()); | ||
+ | }else | ||
+ | { | ||
+ | mysql_select_db($db_name, $link) or die('Could not select database.'); | ||
+ | $result = mysql_query("SHOW tables", $link); | ||
+ | while($row = mysql_fetch_row($result)) | ||
+ | { | ||
+ | print("$row[0]<br>"); | ||
+ | } | ||
+ | } | ||
+ | mysql_close($link); | ||
+ | ?> | ||
+ | </code> |