PHP Database Connection
12:48 PM
PHP Database Connection :
How to use :
Set Current timezone in PHP :
Get Current time in PHP :
$DB = array();
$DB['hostname'] = "localhost";
$DB['username'] = "ccodes_indihire";
$DB['password'] = "indihire@1234";
$DB['name'] = "ccodes_indihire";
function connect(){
global $DB,$CONN;
//print_array($DB);
$CONN = new mysqli($DB['hostname'] , $DB['username'], $DB['password'], $DB['name']);
if ($CONN->connect_errno) {
echo "Failed to connect to MySQL: (" . $CONN->connect_errno . ") " . $CONN->connect_error;
}
return $CONN;
}
How to use :
$CONN = connect();
Set Current timezone in PHP :
date_default_timezone_set('Asia/Kolkata');
Get Current time in PHP :
$current_date = date('Y-m-d H:i:s');
0 comments