我有應用程序我想連接到iphone應用程序我已經完成代碼和PHP代碼問題是,我總是得到不正確的密碼警報視圖。我AAM輸入正確的用戶名和密碼,但再次顯示了錯誤警報視圖將iphone應用程序連接到mysql數據庫
NSString *post =[NSString stringWithFormat:@"UserName=%@&UserPassword=%@",userNameTextField.text, userPasswordTextFiled.text];
NSString *hostStr = @"http://www.myurl.com/emrapp/connect.php?";
hostStr = [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];
}
而且我的服務器端代碼
<?php
$con = mysql_connect("emriphone.db.6420177.hostedresource.com","emriphone","Light12-");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("emriphone", $con);
$u=$_GET['UserName'];
$pw=$_GET['UserPassword'];
$query = sprintf("SELECT UserName,UserPassword from appUsers WHERE UserName='%s' AND UserPassword='%s'", mysql_real_escape_string($u),mysql_real_escape_string($pw));
$login=mysql_query($query,$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);
?>
這個鏈接可以幫助你http://stackoverflow.com/questions/2720288/how-to-connect-with-sqlite-in-iphone – 2012-03-19 07:19:09
這是我的鏈接親愛的,但我有同樣的問題 – user1263350 2012-03-19 07:28:11
字符串中的服務器輸出我越來越是@「」;只有所以這就是爲什麼我認爲它給錯誤可以幫助我在這s – user1263350 2012-03-19 07:56:49