Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $dbServername = "localhost";
- $dbUsername = "root";
- $dbPassword = "";
- $dbName = "loginsystem";
- $conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);
- ?>
- <?php
- $dbServername = "serverexample.hostinger.com";
- $dbUsername = "u123456789_username";
- $dbPassword = "password";
- $dbName = "u123456789_name";
- $conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);
- ?>
- <?php
- # Fill our vars and run on cli
- # $ php -f db-connect-test.php
- $dbname = 'u123456789_name';
- $dbuser = 'u123456789_username';
- $dbpass = 'password';
- $dbhost = 'serverexample.hostinger.com';
- $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";
- }
Add Comment
Please, Sign In to add comment