<?php | |
# Fill our vars and run on cli | |
# $ php -f db-connect-test.php | |
$dbname = 'name'; | |
$dbuser = 'user'; | |
$dbpass = 'pass'; | |
$dbhost = 'host'; | |
$link = mysqli_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'"); | |
mysqli_select_db($link, $dbname) or die("Could not open the db '$dbname'"); | |
$test_query = "SHOW TABLES FROM $dbname"; | |
$result = mysqli_query($link, $test_query); | |
$tblCnt = 0; | |
while($tbl = mysqli_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"; | |
} |
This comment has been minimized.
This comment has been minimized.
Back again. |
This comment has been minimized.
This comment has been minimized.
Thanks. |
This comment has been minimized.
This comment has been minimized.
Hi! Having an issue with a script (stopped working for some reason after many years of running just fine) and trying to test database and server connection. I uploaded the script and it appears to be working, except, it is saying there are no tables, when in fact there are many tables in the database. Does anyone know what the issue may be or able to point me in the right direction? |
This comment has been minimized.
This comment has been minimized.
Thank you for the updated version. This is very handy indeed. |
This comment has been minimized.
This comment has been minimized.
Having trouble understanding how to run the script. I then took the command as you'd hashed out in line 3, and as per below tried to run as root in the var/www directory: root@ip-172-31-33-139:/home/ubuntu# cd /var/www I have set the variables with the correct RDS host and login credentials, which checkout from this machine using the remote mysql access, which works fine, logging in and returning the schema structure with the show databases; mysql command. In your second line hashed out statement, you're suggesting running this under CLI. Could you please provide the syntax? Also, as it's my goal here to understand the general rules / syntax for evaluating php scripts from this micro staging server I"m using, please do comment if what I'm trying to do is possible (ie invoking a php script in the root apache directory as "index.php" to get a browser response linked to the server's url). Any guidance appreciated. Thanks, |
This comment has been minimized.
This comment has been minimized.
Hi there. Are you running this script in /var/www/ ?? Regards J |
This comment has been minimized.
This comment has been minimized.
wonderfull, thanks. |
This comment has been minimized.
This comment has been minimized.
Cool. So It said there is 1 table, and when I added another table, it updated to 2 tables. i assume this is a positive result? |
This comment has been minimized.
This comment has been minimized.
Correct |
This comment has been minimized.
This comment has been minimized.
PHP Warning: mysqli_connect(): php_network_getaddresses: getaddrinfo failed: H�te inconnu. in C:\inetpub\wwwroot\db-connect-test.php on line 10 |
This comment has been minimized.
This comment has been minimized.
If you send me the working fix as pull-request, I could include it into the repository and publish an updated version on SF: |
This comment has been minimized.
This comment has been minimized.
Thank you! |
This comment has been minimized.
works fine thank you