how to connect to mysql? | Sololearn: Learn to code for FREE!
+ 2

how to connect to mysql?

I have got a mysql username and pasword. but its host is localhost how can i connect to it. its a vps hosting on cloudflare. any helps?

19th May 2017, 2:47 PM
Anish Khatri
Anish Khatri - avatar
2 odpowiedzi
+ 2
for php take a look at mysqli_connect() replace localhost by the name or ip of the server.
19th May 2017, 5:04 PM
Mario L.
Mario L. - avatar
+ 3
try to use PDO $bdd=new PDO("mysql:host=$host;dbname=$dbname", $user_db, $pass_db , array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
19th Oct 2017, 11:57 AM
sfeuh
sfeuh - avatar