這個問題在這里已經有了答案: bind_param() 在第一個非數字字符處截斷輸入 1 個回答 昨天關閉。
我有以下php代碼:
$post_id = $_GET["id"];
$stmt = $conn->prepare("SELECT title FROM `posts` WHERE id=?");
$creator = "Anupam";
$stmt->bind_param("i", $post_id);
$result = $stmt->execute();
這對于像http://localhost2/post.php?id=3202. 但我注意到,即使是頁面在被剝離后也喜歡http://localhost2/post.php?id=3202XYZ或http://localhost2/post.php?id=3202xyz/css/style.css像任何東西一樣作業3202。
是否對引數bind_param進行型別轉換?php 檔案沒有提到任何關于它的內容。inti
uj5u.com熱心網友回復:
簡短的回答:是的。
縱觀來源的bind_param,我們可以發現在以下行i的情況:
bind[ofs].buffer = &Z_LVAL_P(param);
這里,Z_LVAL_P指的是 P(ointer) 的 L(ong) VAL(ue) param- “long”是 C 整數資料型別。
uj5u.com熱心網友回復:
是的,它確實。
檢查源代碼:
bind[ofs].buffer = &Z_LVAL_P(param);
Z_LVAL_P獲取整數值。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/400247.html
