在我需要连接并随后查询MySQL数据库的页面中有多次,但我的代码不会让我。我认为这可能与我的文件如何嵌套有关,但没有任何意义。我打开头文件中的SQL连接。违规网页的顶部看起来如下:在PHP中的函数内访问全局变量
<?php
$page_title = 'Dashboard';
include('templates/header.inc'); // includes a 'require_once('mysqli_connect.php') and a small query to the database;
require_once('includes/functions.php');
require_once('includes/dashboard_sql.php'); // Contains functions which connect to database (which are failing.)
?>
我得到的PHP错误
注意:未定义的变量:DBC在/Library/WebServer/Documents/pediatory_site/includes/dashboard_sql.php
其中$ dbc是在mysqli_connect.php中定义的数据库连接。
如果任何人都可以帮助我,这将是伟大的。
每个请求只应连接到数据库一次,并重用该连接。 – webbiedave 2010-05-18 22:31:49
这就是问题,连接变量在某处丢失了? – greenimpala 2010-05-18 22:33:57
你是否包含mysqli_connect.php? – 2010-05-18 22:34:39