我只在某些浏览器上收到此错误,但我不确定原因。我希望这是一个简单的解决方案。听起来应该是这样。这是错误,下面是代码。
警告:mysqli_fetch_array需要参数1到mysqli_result,第71行/home/content/yada/html/myapp/main.php中给出的布尔值
顺便说一句,这是第71行:
while($row = mysqli_fetch_array($result))
及以下是完整代码
$type = $_POST[type];
$user="theUser";
$password="thePassword";
$database="theDatabase";
$TABLE = "user";
@mysql_connect("mydb.com",$user,$password);
@mysql_select_db($database) or die("Unable to select database");
if($_POST[type]) {
$query = "UPDATE $TABLE
SET type = $type
WHERE fbId = $id";
if(mysql_query($query)) {
//echo "Settings saved successfully!";
} else {
echo ("MySQL Error: ".mysql_error());
}
}
$con=mysqli_connect('localhost',"$user","$password","$database");
// Check connection
if(mysqli_connect_errno($con)) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM $TABLE WHERE fbID = $id");
while($row = mysqli_fetch_array($result)) {
$currentType = $row['type'];
//echo $currentType;
}
if ($result = mysqli_query($con, "SELECT * FROM $TABLE WHERE fbID = $id", MYSQLI_USE_RESULT)) {
//echo "True";
//mysqli_free_result($result);
}
答案 0 :(得分:-1)
使用 echo mysqli_error($ con); 显示MySQL服务器在第71行执行SQL查询时给出的错误。这将揭示查询的错误。