我在Trying to get property of non-object in
和if ($fetch_size_id->num_rows > 0)
处获得此else if ($fetch_size_id->num_rows == 0)
。
无法弄清楚导致它的原因。 if条件也不起作用......
当我var_dump($fetch_size_id)
时,我得到bool(false)
。
$fetch_size_id = $conn->query("
SELECT
`sizes`.`size_id`,
`sizes`.`width`,
`sizes`.`ratio`,
`sizes`.`construction`,
`sizes`.`diameter`
FROM `sizes`
WHERE
`sizes`.`width` = '".$conn->real_escape_string($row['5'])."'
AND `sizes`.`ratio` = '".$conn->real_escape_string($row['6'])."'
AND `sizes`.`construction` = '".$conn->real_escape_string($construction)."'
AND `sizes`.`diameter` = '".$conn->real_escape_string($row['7'])."
");
if ($fetch_size_id->num_rows > 0) {
$fetch_size_id = $fetch_size_id->fetch_object();
$temp_size_id = $fetch_size_id->size_id;
} else if ($fetch_size_id->num_rows == 0) {
//create new
} else {
//error
}
我忽略了什么吗?
答案 0 :(得分:0)
您没有检查变量$fetch_size_id
if (isset ($fetch_size_id){
if ($fetch_size_id->num_rows) {
$fetch_size_id = $fetch_size_id->fetch_object();
$temp_size_id = $fetch_size_id->size_id;
} else{
//create new
}
} else {
//error
}