[問題] 將密碼加密後再寫入資料庫??(解決)
01 $str='Hello';
18 mysql_query("INSERT INTO member (ID ,password ,name)
19 VALUES ('s46545646aas', '"sha1($str)"', 'sss')");
 ̄ ̄ ̄ ̄ ̄ ̄ ̄
請問這樣弄哪裡有錯嗎??
'"sha1('hello')"' 這樣寫也不行
Parse error: syntax error, unexpected T_STRING in F:\share\tets.php on line 19
請問要怎麼正確使用sha1()這個函數加密密碼然後再存到資料庫裡面??
18 mysql_query("INSERT INTO member (ID ,password ,name)
19 VALUES ('s46545646aas', '".sha1($str)."', 'sss')");
或
17 $pass = sha1($str);
18 mysql_query("INSERT INTO member (ID ,password ,name)
19 VALUES ('s46545646aas', '$pass', 'sss')");
感謝
原因就是出在不能直接在query中做php的動作 要斷行或在外面做
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.122.184.102
推
02/21 17:20, , 1F
02/21 17:20, 1F
→
02/21 17:21, , 2F
02/21 17:21, 2F
→
02/21 17:25, , 3F
02/21 17:25, 3F
※ 編輯: yangpika 來自: 140.122.184.102 (02/21 17:28)
PHP 近期熱門文章
PTT數位生活區 即時熱門文章
0
18