Free Hosting Tutorials

How to check mysql connection in cpanel

1.Log into the cpanel.

2.Choose mysql > create a database and add the user to that database.

3.Give full previleage to that user.

4.Now upload the test.php file into the public_html

with the following contents

<?
$hostname=”localhost”;
$user=”root”;
$pass=”root1″;
$dbase=”emp”;
$connection = mysql_connect(“$hostname” , “$user” , “$pass”);
$db = mysql_select_db($dbase , $connection);
echo “got the connection”;
?>

here,

hostname=localhost

user=db_user

password=password

dbase=database name

5.After doing this,call it from the browser as

http://domainname/test.php

You sholud get the message as “got the connection”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.