Difference between revisions of "Connecting to mysql"
From MyWiki
(Created page with "<source lang="php"> //closing Example (MySQLi Procedural) mysqli_close($conn); </source>") |
|||
Line 1: | Line 1: | ||
<source lang="php"> | <source lang="php"> | ||
− | //closing | + | |
+ | ////Example (MySQLi Procedural) | ||
+ | <?php | ||
+ | $servername = "localhost"; | ||
+ | $username = "username"; | ||
+ | $password = "password"; | ||
+ | |||
+ | // Create connection | ||
+ | $conn = mysqli_connect($servername, $username, $password); | ||
+ | |||
+ | // Check connection | ||
+ | if (!$conn) { | ||
+ | die("Connection failed: " . mysqli_connect_error()); | ||
+ | } | ||
+ | echo | ||
+ | |||
+ | |||
+ | //closing the connection | ||
Example (MySQLi Procedural) | Example (MySQLi Procedural) | ||
mysqli_close($conn); | mysqli_close($conn); |
Revision as of 17:46, 10 November 2014
////Example (MySQLi Procedural) <?php $servername = "localhost"; $username = "username"; $password = "password"; // Create connection $conn = mysqli_connect($servername, $username, $password); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } echo //closing the connection Example (MySQLi Procedural) mysqli_close($conn);