我正在为我的应用创建登录和注册。每次运行此代码时,我都会收到此错误:
#import <UIKit/UIKit.h>
#import "THRAppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([THRAppDelegate class]));
}
}
谁能告诉我这是什么意思?我相信它发生在服务器端(PHP)
我不断收到的 JSON 响应也是错误:False
这是php代码:
function registerUser($email, $name, $username, $password){
$uuid = uniqid('', true);
$hash = hashSSHA($password);
$encrypted_password = $hash["encrypted"]; //encrypted password
$salt = $hash["salt"]; //salt password
$register = query("SELECT email FROM users WHERE email='$email' limit 1");
if (count($register['result'])>0) {
errorJson('This email is already registered. Try to login or recover your password.');
}
//try to register the user
$result = query("INSERT INTO users(unique_id, name, email, username, encrypted_password, salt) VALUES('$uuid', '$name', '$email','$username', '$encrypted_password', '$salt', NOW())");
if (!$result['error']) {
//success
login($email, $password);
} else {
//error
//errorJson('Sorry, something went wrong :( . Please try again later.');
errorJson(mysql_error());
}
}
function login($email, $password){
$result = query("SELECT uid, email FROM users WHERE email ='%s' AND password ='%s' limit 1", $email, $password);
if (count($result['result'])>0) {
$salt = $result['salt'];
$encrypted_password = $result['encrypted_password'];
$hash = checkhashSSHA($salt, $password);
//checking for password equality
if ($encrypted_password == $hash) {
//user authentication details are correct
return $result;
//authorized
$_SESSION['uid'] = $result['result'][0]['uid'];
print json_encode($result);
}
} else {
//not authorized
errorJson('Wrong Email and password combination.');
}
}
function hashSSHA($password){
$salt = sha1(rand());
$salt = substr($salt, 0,10);
$encrypted = base64_encode(sha1($password . $salt, true) . $salt);
$hash = array("salt" => $salt, "encrypted" => $encrypted);
return $hash;
}
/*
*Decrypting password
*#param salt. pasword
returns hash string
*/
function checkhashSSHA($salt, $password){
$hash = base64_encode(sha1($password.$salt, true) . $salt);
return $hash;
}
Xcode 错误
2012-10-11 15:04:42.528 Thryfting[1457:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFBoolean isEqualToString:]: unrecognized selector sent to instance 0x1883964'
*** First throw call stack:
(0x1752012 0x1577e7e 0x17dd4bd 0x1741bbc 0x174194e 0x6184af 0x618674 0x8b0706 0x8be578 0x8beb50 0x1b5fb 0x1ce4c 0x1e6fb 0xed99 0x1f0753f 0x1f19014 0x1f097d5 0x16f8af5 0x16f7f44 0x16f7e1b 0x2c827e3 0x2c82668 0x4bf65c 0x2bad 0x2ad5 0x1)
libc++abi.dylib: terminate called throwing an exception