这可能是一个非常愚蠢的错误,但我找不到它。任何帮助,将不胜感激。尝试获取select查询中的行数。即使应该返回行,它也始终返回零。
$DESC_id = $_POST['desc_id']; //array
$DESC = $_POST['desc']; //array
$DESC_hr = $_POST['desc_hr']; //array
$DESC_rt = $_POST['desc_rt']; //array
$DESC_amt = $_POST['desc_amt']; //array
...
if(!empty($DESC)){
foreach ($DESC as $i => $b) {
//SQL Injection Prevention
$v_DESC_id[$i]="'" . $conn->real_escape_string($DESC_id[$i]) . "'";
$v_DESC[$i]="'" . $conn->real_escape_string($DESC[$i]) . "'";
$v_DESC_hr[$i]="'" . $conn->real_escape_string($DESC_hr[$i]) . "'";
$v_DESC_rt[$i]="'" . $conn->real_escape_string($DESC_rt[$i]) . "'";
$v_DESC_amt[$i]="'" . $conn->real_escape_string($DESC_amt[$i]) . "'";
$sql = "SELECT * FROM estimate_desc WHERE id = ?";
$stmt = $conn->prepare($sql);
if($stmt ===false){
trigger_error('Wrong SQL: ' .$sql. ' Error: ' . $conn->error, E_USER_ERROR);
}
$stmt ->bind_param('i', $v_DESC_id[$i]);
$stmt->execute();
$result = $stmt->get_result();
//this prints out the sql query which I've double checked in myadmin and it returns a
echo 'SELECT * FROM estimate_desc WHERE id = '.$v_DESC_id[$i];
$q_row_num = $result->num_rows;
echo '<br>row number is '.$q_row_num;
$stmt->close();
...
}