我有一個mysqli數據獲取問題。我將嘗試通過示例來解釋我的問題:mysqli獲取問題
我想從表中獲取條目(由不同的人員)。現在我想在另一個表格中查找每個獲取的人的姓名,並查看他是否有任何照片。 我的代碼如下,但其沒有工作,我收到以下錯誤:
mysqli::prepare() [mysqli.prepare]: All data must be fetched before a new statement prepare takes place
Call to a member function fetch() on a non-object in ...
我的代碼:
if ($stmt = $this->mysqli->prepare("SELECT entry, author, time FROM messages WHERE user = ?")) {
$stmt->bind_param("s", $user_name);
$stmt->execute();
$stmt->bind_result($entry, $author, $time);
while ($stmt->fetch()) {
if ($stmt = $this->mysqli->prepare("SELECT photo_id FROM photos WHERE user = ?")) {
$stmt->bind_param("s", $author);
$stmt->execute();
$stmt->bind_result($photo_id);
}
//echo $photo_id;
}
$stmt->close();
}
我會任何幫助非常感謝。
檢查我的答案。它適合你嗎?附:如果有,請不要忘記接受答案。 – Rihards 2011-04-02 22:19:00