PHP Tutorial - MySQL Databases
Before you can use MySQL, you'll have to have supportbot
create a username and database for you.
The below script will attempt to connect to the MySQL server and open a database.
This is a quick method to verify MySQL works on your web hosting account.
Verifying MySQL Installation using PHP
<?php
$link = mysql_connect("localhost","username","password");
if(! $link)
die("Could not connect to MySQL");
else
print("Connected to MySQL server<P>");
$database = "database";
mysql_select_db($database)
or die ("could not open $database: ".mysql_error() );
print "Opened database \"$database\"<P>";
mysql_close($link);
print "Everything works";
?>
|
|
Replace username with your MySQL username, password
with the password and finally replace database with your database name.
If all goes well, the PHP script will inform you it connected to the MySQL server and
it opened the database.
If anything goes wrong, it will tell you why so you can correct
your username/password or database settings.
PHP support is enabled on all web site hosting plans.