How to connect Php to My Sql Using Cpanel

Before you need to add or Connect the Database you need have one mysql Database and one database user name and it password.
First we need to create My SQL database and user then we need to add the user to the database for which one you want to connect.

Example Sample coding to Connect PHP coding to My SQl Database
<?php
mysql_connect("localhost","onlineda_onlined","online123") or die("Connection Error");
mysql_select_db("onlineda_onlined")or die("Unable to connect My sql Database Connection Error");
date_default_timezone_set("Asia/Calcutta");
?>
Database username:onlineda_onlined
Database Password: online123
Database Name: onlineda_onlined
Host: localhost

If it is not connected.
Then you will get the error message “Unable to connect My sql Database Connection Error”.cpanel

Related post