我有以下功能,它应该采用用户凭据并验证它们。如果它们有效,则将它们插入数据库。插入后检查它们是否成功插入。如果不返回false。如果电子邮件一开始就无效,则返回 false。Eclipse + Aptana 插件报告最后一个 else 部分的语法错误。当我尝试使代码合理化时,它似乎应该正常运行。我可以确认所有的 {brackets} 都在正确的层次顺序
这是代码:
public function storeUser($name, $email, $password) {
$uuid = uniqid('', true);
$hash = $this->hashSSHA($password);
$encrypted_password = $hash["encrypted"]; // encrypted password
$salt = $hash["salt"]; // salt
if((filter_var($email, FILTER_VALIDATE_EMAIL)) && preg_match('/@.+\./', $email)); { //validate the email
$result = mysql_query("INSERT INTO users(unique_id, name, email, encrypted_password, salt, created_at) VALUES('$uuid', '$name', '$email', '$encrypted_password', '$salt', NOW())");
// check for successful store
if ($result) {
// get user details
$uid = mysql_insert_id(); // last inserted id
$result = mysql_query("SELECT * FROM users WHERE uid = $uid");
// return user details
return mysql_fetch_array($result);
} else {
return false; //unsuccessful store
}
else { //THIS IS LINE 45
//not a valid email
return false;
}
}
}
它返回以下错误:
05-23 11:07:10.758: E/JSON(1601): <b>Parse error</b>: syntax error, unexpected T_ELSE in <b>/home/content/40/8529140/html/webapps/projects/functions/DB_Functions.php</b> on line <b>45</b><br />
05-23 11:07:10.758: E/JSON Parser(1601): Error parsing data org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject