MySQLiconfig.php:
<?php
$MySQLi = new mysqli('localhost','root','123','Database') or die('ERROR');
其他文件:
<?php
require 'MySQLiconfig.php';
function DoAQuery($Query){
$MySQLi->query($Query);
}
错误是:
Undefined variable: MySQLi
答案 0 :(得分:-1)
你变量范围错了。在您需要使用的函数global $MySQLi
中,或者您可以作为函数参数传递。