iPhone代碼MySQL查詢語法錯誤在PHP中使用時
當我使用此代碼它始終顯示錯誤密碼,但我輸入正確的憑據。
NSString *post =[NSString stringWithFormat:@"UserName=%@&UserPas sword=%@",userNameTextField.text, userPasswordTextFiled.text];
NSString *hostStr = @"http://www.celeritas-solutions.com/emrapp/connect.php";
= [hostStr stringByAppendingString:post];
NSData *dataURL = [NSData dataWithContentsOfURL: [ NSURL URLWithString: hostStr ]];
NSString *serverOutput = [[NSString alloc] initWithData:dataURL encoding: NSASCIIStringEncoding];
if([serverOutput isEqualToString:@"Yes"]){
UIAlertView *alertsuccess = [[UIAlertView alloc] initWithTitle:@"Congrats" message:@"You are authorized "
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alertsuccess show];
[alertsuccess release];
} else {
UIAlertView *alertsuccess = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Username or Password Incorrect"
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alertsuccess show];
[alertsuccess release];
}
我得到驗證從數據庫中的用戶名和密碼,但它給SQL語法錯誤
You have an error in your SQL syntax; check the manual that corresponds to your MySQLserver version for the right syntax to use near 'AND UserPassword=' at line 1
mysql_select_db("emriphone", $con);
$u=$_GET['UserName'];
$pw=$_GET['UserPassword'];
$check ="SELECT UserName,UserPassword from appUsers WHERE UserName=$u AND UserPassword=$pw";
$login=mysql_query($check,$con) or die(mysql_error());
if(mysql_num_rows($login)==1){
$row =mysql_fetch_assoc($login);
echo 'YES'; exit;
}
else{
echo'NO';exit;
}
mysql_connect($con);
爲什麼你已經標記了這個問題的** ** iPhone? – Devang 2012-03-19 05:39:02
,因爲我用iPhone應用程序連接這個數據庫並驗證密碼和用戶名 – user1263350 2012-03-19 06:23:31
那麼是什麼?沒有任何與iPhone相關的代碼! – Devang 2012-03-19 06:32:38