-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnect.php
More file actions
26 lines (21 loc) · 839 Bytes
/
Connect.php
File metadata and controls
26 lines (21 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
$errMsg = 'Could not connect to database'.'<br/>';
$sqlHost = 'localhost';
$sqlUser = 'root';
$sqlPass = '';
$database = 'mydatabase';
//mysql_connect($sqlHost, $sqlUser, $sqlPass) || die($errMsg); //Example of connecting to server. The @ symbol will remove any
//mysql_select_db($database); //default error msg. And instead we use || die() meaning
//if it doesnt connect kill page and show the message in $errMsg
//This way can also be used the mysqli_connect way is usually better
//$mysqlcon=mysqli_connect($sqlHost, $sqlUser, $sqlPass) or die('could not connect.');
//MySQLi_select_db($mysqlcon , $database) or die('no such db');
if(mysql_connect($sqlHost, $sqlUser, $sqlPass) && mysql_select_db($database))//Connecting to the database
{
echo 'Connected to database'.'<br/>'.'<br/>';
}
else
{
die($errMsg);
}
?>