資料庫連線
1,新conn.inc.php檔案:
#定義資料庫連線常數如下:
<?php define("HOST",'localhost'); define("USER",'root'); define("PWD",'root'); define("DBNAME",'onecms');
2,新mysqli.php檔:
<?php include 'conn.inc.php'; $mysqli=new mysqli(HOST,USER,PWD,DBNAME); if($mysqli->connect_errno){ die('数据库链接出错'.$mysqli->connect_error); }
下次連接資料庫作業只需要引進mysqli.php檔即可