ABHIONLINUX
Site useful for linux administration and web hosting

2009/11/16

Mysql database connection testing

Please put the following code in a php file in the server and access it through a browser to view the result.

Change the username of database user from "root" to your "database-user", followed by the password of the database user from "testuser" to your "database-access-password".

If the connection was successful the page will display Success. Other wise it will display Could not select DB.

Code:

php
$con=mysql_connect("localhost","root","testuser") or die("Could not connect");
$db=mysql_select_db("test",$con) or die("Could not select DB");
echo "Success";

No comments:

Post a Comment