How do I open a connection to a mysql database using php? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How do I open a connection to a mysql database using php?

16th Apr 2017, 7:15 AM
eddisme
3 Answers
+ 13
<?php $username = "your_name"; $password = "your_password"; $hostname = "localhost"; //connection to the database $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); echo "Connected to MySQL<br>"; ?>
16th Apr 2017, 7:49 AM
Don MTY
Don MTY - avatar
+ 4
$conn = mysqli_connect("host","username", "password","databaseName")
16th Apr 2017, 7:23 AM
h8c
h8c - avatar
16th Apr 2017, 7:23 AM
Yaroslav Pieskov
Yaroslav Pieskov - avatar