if (! empty ( $fname ) && ! empty ( $lname )) {
$query5 = "select * from " . $db_prefix . "customer_det where (fname = '" . $fname . "' and lname = '" . $lname . "')";
$result5 = $mysqli->query ( $query5, MYSQLI_STORE_RESULT ) or die ( mysql_error () );
} else {
$query5 = "select * from " . $db_prefix . "customer_det where phone = '" . $phone . "'";
$result5 = $mysqli->query ( $query5, MYSQLI_STORE_RESULT ) or die ( mysql_error () );
}
while ($row=$result5->fetch_assoc) {
$uid = $row['id'];
$visits = $row['visits'];
}
var_dump($uid);
var_dump($visits);
var_dump($result5);
var_dump($fname);
var_dump($lname);
我不确定我要去哪里错了。我在 phpMyAdmin SQL 查询框中运行这两个查询,它返回一个行集。然后,当我在 PHP 中运行它并 var_dump 变量时,$uid 返回 NULL 以及 $visits。这是 var 转储:
NULL NULL object(mysqli_result)#4 (5) { ["current_field"]=> int(0) ["field_count"]=> int(34) ["lengths"]=> NULL ["num_rows"]=> int(1) ["type"]=> int(0) } string(6) "Wesley" string(6) "Snipes"
任何建议都会很棒。