MYSQLi Tutorial for Beginners – how to create MySQLi connection with php in simple and easy steps starting from basic to advanced level.
To create connection 4 parameter is required : “hostname” , “username“, “password” and “database name”
see below..how to do it..
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
<?php $host="localhost"; $username="username"; $password="password"; $db="database name"; $conn=new mysqli($host,$username,$password); if($conn->connect_error) { echo "database not connected"; } else{ echo "database connected successfully"; if(mysqli_select_db($conn,$db)) { echo "<br>"; echo "database selected"; }else{ echo "<br>"; die("database not selected"); } } ?> |
if you are using xampp or wamp then by default username is root and password is blank.
Also you can check our video tutorials:
Pradeep Maurya is the Professional Web Developer & Designer and the Founder of “Tutorials website”. He lives in Delhi and loves to be a self-dependent person. As an owner, he is trying his best to improve this platform day by day. His passion, dedication and quick decision making ability to stand apart from others. He’s an avid blogger and writes on the publications like Dzone, e27.co