What is the best way for connecting php to the database? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is the best way for connecting php to the database?

6th Apr 2018, 6:37 AM
Mohamad Shamsi
Mohamad Shamsi - avatar
3 Answers
+ 2
<?php /* Attempt MySQL server connection. */ $mysqli = new mysqli("localhost", "root", "", "demo"); // Check connection if($mysqli === false){ die("ERROR: Could not connect. " . $mysqli->connect_error); } echo "Connect Successfully. Host info: " . $mysqli->host_info; ?>
6th Apr 2018, 7:14 PM
Sanjeev Bomma
Sanjeev Bomma - avatar
0
thanks
6th Apr 2018, 8:56 PM
Mohamad Shamsi
Mohamad Shamsi - avatar