<?php
$servername = "localhost";
$username = "root";
$password = "";
$db = "customer";
$conn = mysql_connect($servername, $username, $password);
$link = mysql_select_db($db);
//if (!$conn) {
//die("Connection failed: " . mysqli_connect_error());}
//echo "Connected successully";
//if (!$link) {
//die("db Connection failed: " . mysqli_connect_error());}
//echo "db also Connected successfully";
?>
mysql connection by php
3 Responses
The mysql driver only connects to a database. MySQL = D.
PDO:
The PDO he makes 12 kinds of database, if not mistaken.
Performance:
In terms of performance, mysqli, out in front, but the difference is minimal.
Recommendation:
I recommend using the PDO, by its advantages connections in various database, this can help in the future if you want to migrate to another database.
Write a comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.