在我的主页上我有
//connection to database
require_once('inc/conn_db.in');
我还有一个文件
// Device Search::
require_once('inc/ProductSearch.php');
从主页面进行的查询工作正常。 问题出在我从第二个require_once文件('inc / ProductSearch.php')运行查询时
我可能完全错了,但我认为数据库连接已打开,我应该能够在主页面打开时进行查询。
我能够运行查询的唯一方法是当我包含require_once('inc / conn_db.in'); 在第二个文件中。
这是正常行为还是我做错了
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;
}
#
感谢任何帮助或指示