有人可以帮我这个吗?这让我很生气。我看不出有什么不对......
$stmt_query = "SELECT aboutme_profile FROM ProfilesAboutMe WHERE aboutme_profile = ? LIMIT 1";
$stmt = mysqli_prepare($sql_connect, $stmt_query);
mysqli_stmt_bind_param($stmt, "i", $return_profile_id);
mysqli_stmt_execute($stmt);
echo mysqli_stmt_num_rows($stmt); // Always shows 0
echo $return_profile_id; // Shows correct value
if (mysqli_stmt_num_rows($stmt) == 0)
{
$stmt_query = "INSERT INTO ProfilesAboutMe (aboutme_profile, aboutme_text) VALUES (?, ?)";
$stmt = mysqli_prepare($sql_connect, $stmt_query);
mysqli_stmt_bind_param($stmt, "is", $return_profile_id, $aboutme);
mysqli_stmt_execute($stmt);
}
两个查询都没问题,因为我已将它们复制并粘贴到phpMyAdmin中,并且在手动绑定params时它们运行正常。
警告:mysqli_stmt_bind_param()期望参数1为mysqli_stmt,布尔值在
中给出
SELECT aboutme_profile FROM ProfilesAboutMe WHERE aboutme_profile = 123456789 LIMIT 1
当我在PHP中编辑查询以硬编码aboutme_profile值时,我得到0结果。我在MySQL中运行相同的查询并得到1个结果。