Database Connec...LOGIN

Database Connectivity

1, create a new conn.inc.php file:

Define the database connection constants as follows:

<?php
define("HOST",'localhost');
define("USER",'root');
define("PWD",'root');
define("DBNAME",'onecms');

2, create a new mysqli.php file:

<?php
include 'conn.inc.php';
$mysqli=new mysqli(HOST,USER,PWD,DBNAME);
if($mysqli->connect_errno){
    die('数据库链接出错'.$mysqli->connect_error);
}

The next time you connect to the database, you only need to import the mysqli.php file.

Next Section
<?php echo "mysqli的用法";
submitReset Code
ChapterCourseware