This is very important post for PHP learner/beginner. Today I will tell you about how to make connection PHP with Database using Mysql Query.
How to make connection php with database
Php provides connection string function to make connection in between database and PHP.
Please check it out connection string as given below :-
Here we will pass Three connection parameters
Hostname, username and password we have to put it or pass in parameters
Parameters are given as below(Also know as connection parameter):
Hostname :localhost
Username :root
Password : Enter password if available/leave blank
In case of live hosting we can changes these parameter according to live MySQL username and password its up to you what you have created your MySql username and password.
We can show example according to local envoirment as well as live.
First step: set connection parameter value and establish connection string
For local Environment:
1 2 3 4 5 6 7 |
$hostname =”loalhost”; $username=”root”; $Password=””; // by default in local Environment it’s value is blank $css3transcon = mysql_connect($hostname, $username, $Password); |
For Live Environment:
1 2 3 4 5 6 7 |
$hostname =”loalhost”; $username=”democss3”; $Password=”democss3”; $css3transcon= mysql_connect($hostname, $username, $Password); |