嗨,我正在尝试确定用户的状态,以便它将检查该用户的帖子数量并回显结果,当我使用mysql时,它工作正常,但将其转换为mysqli后,给了我一些错误
这是我的代码:
<?php
if(!isset($_COOKIE['loggedin'])){
header("location:index.php");
}
session_start();
if(!isset($_SESSION['user'])){
header("location: index.php");
}
else {
?>
<?php
$con=mysqli_connect("localhost","root","123","user");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$resule = "SELECT count(ID) from save_data where username = '".$_SESSION['user']."'"
or die(mysql_error());
$result = $con->query($resule);
$row = $result->fetch_array(MYSQLI_NUM);
echo $row[0], $row[1];
?>
<?php }?>
错误:
Notice: Undefined offset: 1 in C:\xampp\htdocs\mysql_login\status.php on line 30
尝试$row[1]
从以下位置删除:
echo $row[0], $row[1];
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句