这是我使用的当前连接文件,我正在考虑将连接公开,以便我可以轻松地到处获取连接,但我不知道如何编写它。
<?php
define ("DB_HOST", "AccDatabase2"); // set database host
define ("DB_USER", "ers"); // set database user
define ("DB_PASS","ers"); // set database password
define ("DB_NAME","AccDatabase2"); // set database name
$link_mssql = odbc_connect(DB_HOST, DB_USER, DB_PASS) or die("Couldn't make connection.");
答案 0 :(得分:0)
将此代码保存在connect.php文件中。
connect.php
<?php
define ("DB_HOST", "AccDatabase2"); // set database host
define ("DB_USER", "ers"); // set database user
define ("DB_PASS","ers"); // set database password
define ("DB_NAME","AccDatabase2"); // set database name
$link_mssql = odbc_connect(DB_HOST, DB_USER, DB_PASS) or die("Couldn't make connection.");
然后根据存储文件的路径将其包含在其他文件中。
index.php
<?php
include_once('connect.php');
echo 'included connection';