Skip to content

Instantly share code, notes, and snippets.

@emresaracoglu
Forked from M165437/db-connect-test.php
Created December 2, 2017 08:08
Show Gist options
  • Select an option

  • Save emresaracoglu/2de2c07c7555bea350cc1b4d0db35c07 to your computer and use it in GitHub Desktop.

Select an option

Save emresaracoglu/2de2c07c7555bea350cc1b4d0db35c07 to your computer and use it in GitHub Desktop.
Script for a quick PHP MySQL DB connection test.
<?php
$dbname = 'db-name';
$dbuser = 'db-user';
$dbpass = 'db-pass';
$dbhost = 'db-example-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);
while($row = mysql_fetch_array($result)) {
echo $row[0]."<br />\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment