看板 PHP 關於我們 聯絡資訊
嗯,真的是見鬼,不過專案在趕也沒時間抓。 幾個例子分享: 環境。PHP5.1.6 / CentOS / Apache 2.2.3 案例1: <form action = "1.php" method = "GET"> <input type = "text" name = "id" value = "123"> <input type = "text" name = "di" value = "456"> <input type = "submit" value = "TEST"> </form> 1.php $_GET[id] OK It's work. $_GET[di] NULL 後來,把di改成dis解決。 案例2: <form action = "1.php" method = "POST"> <input type = "text" name = "bc" value = "123"> <input type = "text" name = "mytb" value = "456"> </form> 1.php $_POST[bc] OK It's work. $_POST[mytb] NULL 後來,改這樣才抓的到 $_POST["mytb"]. 然後我的CODE變這樣。 $q="INSERT INTO TB SET id = '".$_POST[bc]."', tb = '".$_POST["mytb"]."'"; 厚!! 我該去拜拜了嗎 -- 小惡魔的家 http://blog.pixnet.net/shiuju/ -- -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.124.142.152
JeffMcBride:不加引號也可以嗎? 12/28 16:56
JeffMcBride:還是你開了register_globals 12/28 16:58
chchwy:$_GET[di] 是不好的寫法 應該要寫成$_GET['di'] 12/28 17:26
chchwy:如果把E_NOTICE打開應該會警告 12/28 17:26
chchwy:因為PHP會先假定di是個constant,找不到之後才轉成字串'di' 12/28 17:27
appleboy46:$_POST[bc] 這樣寫效能會有差 12/28 22:13
MOONRAKER:我看效能小事,ambiguity的問題比較大。 12/29 00:07
linhomeyeu:都加引號不就好了@@ 省那些時間 debug反而頻繁 12/30 03:10