Questo semplice script php verifica la funzionalità di un database MySQL
Come risultato, fornisce l'elenco delle tabelle attive nel database.
<?php
$connect=mysql_connect('dbserver','dbuser','dbpassword') or die('Could not connect: ' . mysql_error());
mysql_select_db('dbname') or die('Could not open the db');
$showtablequery='SELECT * FROM `records` LIMIT 0 , 30';
echo 'Connected!';
$query_result=mysql_query($showtablequery);
while($showtablerow = mysql_fetch_array($query_result))
{
echo $showtablerow[0].' ';
}
Explanation about the variables used in the script:
dbserver: Mention the value as localhost for Linux Hosting (cPanel). For Windows Hosting (Plesk), MySQL Server IP needs to be mentioned
dbname: Specify complete database name including the prefix. For example, reseloaq_mysql.
dbuser: Mention the database user associated with the database.
dbpassword: Mention the password for the above database user.
- MySQL, php
- 2 Utenti hanno trovato utile questa risposta