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