[問題] 將密碼加密後再寫入資料庫??(解決)

看板PHP作者 (狗狗洋ˇ洋)時間17年前 (2009/02/21 17:18), 編輯推噓1(102)
留言3則, 2人參與, 最新討論串1/1
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
mysql_query("INSERT.....'".sha1($str)."','sss'");
02/21 17:20, 1F

02/21 17:21, , 2F
斷行要用 . concate 否則會出現問題
02/21 17:21, 2F

02/21 17:25, , 3F
謝了。剛剛有想到也可以先在QUERY外先加密後再傳
02/21 17:25, 3F
※ 編輯: yangpika 來自: 140.122.184.102 (02/21 17:28)
文章代碼(AID): #19dyRA4p (PHP)
文章代碼(AID): #19dyRA4p (PHP)