[請益] 幫找錯誤!!!

看板PHP作者 (lina)時間17年前 (2008/06/07 17:02), 編輯推噓3(307)
留言10則, 4人參與, 最新討論串1/1
不好意思我是新手 如果問的問題太簡單請見諒 我要寫的是"帳號密碼驗證" 我先在資料庫設了兩組帳號密碼 變數為 u-id 跟 u-pass 我的資料庫名稱是id_pass 以下是我的程式碼 <? header("Content-Type: text/html; charset=utf-8"); include"./sql.php"; session_start(); $data=$_db->my_com("select u-id,u-pass from id_pass limit 1"); $data_array=$_db->my_com($data); if($data_array[0][u-id]!=$_POST[id] or $data_array[0][u-pass]!=$_POST[pass]){ echo"error!; exit;} else{ session_register("aid"); $_SESSION[aid]=$_POST[id]; echo"welcome"; } } ?> 無論輸入對的或錯的帳號密碼都顯示出 Unknown column 'u' in 'field list' 我看不懂這個錯誤訊息的意思 不知道哪邊有寫錯呢? 懇請高手幫忙解答 謝謝! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.119.141.21

06/07 17:56, , 1F
try select `u-id`,`u-pass`
06/07 17:56, 1F

06/07 18:12, , 2F
出現的是You have an error in your SQL syntax; check
06/07 18:12, 2F

06/07 18:12, , 3F
the manual that corresponds to your MySQL server
06/07 18:12, 3F

06/07 18:13, , 4F
version for the right syntax to use near 'Resource
06/07 18:13, 4F
※ 編輯: wuwangzu 來自: 140.119.141.21 (06/07 18:15)

06/07 18:15, , 5F
id #4' at line 1
06/07 18:15, 5F

06/07 22:55, , 6F
data_array這列用法錯吧
06/07 22:55, 6F

06/07 23:01, , 7F
把欄位名稱改成 u_id u_pass 試試看
06/07 23:01, 7F

06/07 23:01, , 8F
- 改成底線
06/07 23:01, 8F

06/08 02:23, , 9F
已經改過還是一樣....
06/08 02:23, 9F

06/09 14:35, , 10F
$data_array[0][u-id] 這個部分變數用$ 不是變數用''
06/09 14:35, 10F
文章代碼(AID): #18IawwID (PHP)
文章代碼(AID): #18IawwID (PHP)