php require\u once(“数据库连接文件”)不起作用

ilmyapht  于 2021-06-25  发布在  Mysql
关注(0)|答案(0)|浏览(176)

在我的主页上我有我的

//connection to database
require_once('inc/conn_db.in');

我还有一个文件

// Device Search::
require_once('inc/ProductSearch.php');

从主页进行的查询工作正常。问题在于,当我从第二个require\u once文件('inc/productsearch.php')运行查询时
我可能完全错了,但我认为数据库连接是打开的,我应该能够在主页打开时进行查询。
运行查询的唯一方法是包含require_once('inc/conn_db.in');在第二个文件中。
这是正常的行为还是我做错了什么
连接数据库的内容:


############################################################ 

// Create Script to Connection to the Database

    $conn = mysql_connect("localhost", "$$$$$", "$$$$$$");
// Check if the connection to the database Server can be created
    if (!$conn) {
        echo "Unable to connect to DB: " . mysql_error();
        exit;
    }
// Check if it can find the Database on the Database Server 
    if (!mysql_select_db("$$$$$$")) {
        echo "Unable to select mydbname: " . mysql_error();
        exit;
    }

任何帮助或指导都将不胜感激

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题