看,我已将我的php分为3个文件,控制器,函数,数据库连接 Controller.php这样:
require_once "inc/link.php"; //MySQLi connection
require_once "inc/functions.php" //Functions
login();
Link.php:
$link = mysqli_connect("localhost","root","","database");
的functions.php:
function login(){
$sql = "SELECT * FROM users WHERE username='$u' AND password='$p'";
$query = mysqli_query($link, $sql);
//Other code here...
}
它给了我错误:注意 functions.php 中未定义的变量链接 3
如果我写得非常好,为什么会这样呢?