有很多相关问题的帖子,但问题仍然存在,对不起,请帮我解决这个问题。
<?php
$dbhost="localhost";
$dbuser="root";
$dbpass="";
$dbase="cms";
$connection=mysqli_connect("$dbhost","$dbuser","$dbpass","$dbase");
if($connection=mysqli_connect_errno()){
echo "Error estabilishing conection : ".mysqli_connect_error(). "(" .mysqli_connect_errno().")";
}
?>
<?php
$query = "SELECT * FROM pages";
$result = mysqli_query($connection, $query);
if(!$result){
die("Database query failed..");
}
?>
答案 0 :(得分:3)
行
if($connection=mysqli_connect_errno()){
将mysqli_connect_errno()
分配给$connection
变量。
此行应替换为:
if (!$connection) {
完整的连接代码是:
$connection=mysqli_connect("$dbhost","$dbuser","$dbpass","$dbase");
if(!$connection){
echo "Error estabilishing conection : ".mysqli_connect_error(). "(" .mysqli_connect_errno().")";
}