+ 2
How to connect mysql in php???
Hey please say me how to connect mysql in php. i know the mysqli method. please someone provide me the simple method... thanks in advance.šš
2 Answers
+ 7
Php Ways of connection to database
MySql Object oriented:
<?php $mysqli = new mysqli("localhost", "username", "password", "dbname");
$result = $mysqli->query("SELECT lastname FROM employees"); ?>
PDO :
<?php $myPDO = new PDO('mysql:host=localhost;dbname=dbname', 'username', 'password');
$result = $myPDO->query("SELECT lastname FROM employees");
?>
Mysql procedural:
<?php mysql_connect('localhost','username','password');
mysql_select_db("dbname");
$result = mysql_query('SELECT lastname FROM employees');
?>
+ 4
Thanks Mr. Khan i liked the Mysql procedural