note 117706 deleted from class.mysqli-sql-exception by philip
| From: | philip@php.net | Date: | Wed, 02 Sep 2015 23:36:36 +0000 |
| Subject: | note 117706 deleted from class.mysqli-sql-exception by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-203590@lists.php.net to get a copy of this message | ||
Note Submitter: MOMANI
----
use this format its efficient, good and object oriented
#constants.php
<?php
// Database Constants
define("DB_SERVER", "localhost");
define("DB_USER", "root");
define("DB_PASS", "");
define("DB_NAME", "");
?>
#connection.php
<?php
session_start();
require("constants.php");
// 1. Create a database connection
$link = new mysqli(DB_SERVER, DB_USER, DB_PASS);
if (!$link) {
die("Database connection failed: " . mysql_error());
}
// 2. Select a database to use
$db_select = $link->select_db(DB_NAME);
if (!$db_select) {
die("Database selection failed: " . mysql_error());
}
?>