0% found this document useful (0 votes)
5 views1 page

PHP Database Connection Script

The document is a PHP script that defines constants for database connection parameters such as host, username, password, and database name. It sets the default timezone to Asia/Karachi and attempts to connect to the database using the mysqli class. If the connection fails, it displays an error message and exits the script.

Uploaded by

Nasif Tahmid
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

PHP Database Connection Script

The document is a PHP script that defines constants for database connection parameters such as host, username, password, and database name. It sets the default timezone to Asia/Karachi and attempts to connect to the database using the mysqli class. If the connection fails, it displays an error message and exits the script.

Uploaded by

Nasif Tahmid
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

<?

php
define('DB_HOST', 'ENTER_DB_HOST');
define('DB_USERNAME', 'ENTER_DB_USERNAME');
define('DB_PASSWORD', 'ENTER_DB_PASSWORD');
define('DB_NAME', 'ENTER_DB_NAME');

date_default_timezone_set('Asia/Karachi');

// Connect with the database


$db = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME);

// Display error if failed to connect


if ($db->connect_errno) {
echo "Connection to database is failed: ".$db->connect_error;
exit();
}

You might also like