長話短說,我這一步得到:PHP庫MySQLi bind_param()混亂
$stmt = $mysqli->prepare($sql);
$stmt->bind_param("s",$_GET['slug']);
但我如何得到的結果爲關聯數組完全糊塗了。我試圖
$stmt = $mysqli->prepare($sql);
$result = $stmt->bind_param("s",$_GET['slug']);
while ($row = $result->fetch_assoc()) {
printf ("%s (%s)\n", $row["website_name"], $row["subheading"]);
}
,我不認爲我可以使用$mysqli->query($query)
而不是事先準備好的聲明,因爲那似乎是它給我留下了開放的SQL注入攻擊。然而,這是PHP文檔中用於執行我想要的操作的一小部分代碼。所以我找不到任何能顯示如何將已準備好的語句的結果並將其移入關聯數組的任何內容。有人知道嗎?它甚至有可能嗎?
首先第一件事情 - 你有你的綁定參數後,執行查詢。 - > http://us2.php.net/manual/en/mysqli-stmt.execute.php – Jon 2013-05-07 18:13:18
可能的重複[是否有可能在使用bind \ _param時獲取\ _object? (PHP/MySQLi)](http://stackoverflow.com/questions/5287298/is-it-possible-to-fetch-object-while-using-bind-param-php-mysqli) – Barmar 2013-05-07 18:20:18