Tutorial 3 – Connecting To A Database
| In: 3. Database Connect | 7,914 views
Video Tutorial
Video Source Code
File: config.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <?php // MySQL Tutorial 3 - Connecting To A Database // CREATE CONNECTION TO DATABASE $user = "root"; $pass = ""; $database = "phoneBook"; $server = "localhost"; // Syntax: mysql_connect("servername","username","password"); $connect = mysql_connect($server, $user, $pass) or die ('Connection To Server Failed'); // Syntax: mysql_select_db("databaseName", $connect); mysql_select_db("$database", $connect) or die ('Connection To Database Failed'); // CLOSE CONNECTION mysql_close($connect); ?> |