你好,我只是堅持語法,任何人都可以幫我下一個代碼?類下的會話
class User {
protected $userID = preg_replace('#[^0-9]#i', '', $_SESSION['user_id']);
protected $useremail = preg_replace('#[^[email protected]_.-]#i', '', $_SESSION['user']);
protected $userPassword = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION['user_password']);
public function CheckUserLogin(){
if(!isset($_SESSION['user'])){
header("location: login.php");
exit();
}
//Try to find user from session data in database
$sql = "SELECT * FROM users WHERE id = '$this->userID' AND email = '$this->useremail' AND password = '$this->userPassword' LIMIT 1";
$res = mysql_query($sql) or die(mysql_error());
$userMatch = mysql_numrows($res);
if ($userMatch == 0) {
header("location: login.php");
exit();
}
}
}
和什麼問題: – genesis
解析錯誤:語法錯誤,意外 '(',希望 '' 或 ';' 在C:\ XAMPP \ htdocs中\社會\庫\用戶。 php on line 6 我不能做保護$ userPassword = preg_replace('#[^ A-Za-z0-9] #i','',$ _SESSION ['user_password']);我現在不是爲什麼 – Stefan