我无法找到答案,因为这个问题被问了很多次..但是我仍然需要你的帮助...我是php的新手...
<?php
require_once 'dbconnect.php';
session_start();
$_SESSION['user'] = 1;
// if session is not set this will redirect to login page
if( !isset($_SESSION['user']) ) {
header("Location: index.php");
exit;
}
// select loggedin users detail
$sql = "SELECT * FROM user WHERE userId=".$_SESSION['user'];
$result = $conn->query($sql);
while($row = $result->fetch_array()) {
$userRow[] = $row;
}
mysqli_close($conn);
?>
在这一行找到了问题:
while($row = $result->fetch_array()) {
我尝试了这里提出的问题的方法..然后为我返回同样的错误...
编辑2: 即使我设置会话开始() 它仍然给我带来同样的致命错误...... 通过添加会话start(),它给我带来了另一个错误
Notice: A session had already been started - ignoring session_start()