0
iPad 앱을 통해 온라인으로 액세스하는 MySQL DB에 일부 값을 입력하려고합니다.온라인 데이터베이스에 데이터 삽입
은 데이터를 보냅니다
if(txtInput != nil){
NSString *postVars = [NSString stringWithFormat:@"id=%d&input=%@", index, txtInput.text];
NSLog(@"%d",index);
index++;
NSData *data = [postVars dataUsingEncoding:NSUTF8StringEncoding];
NSString *strURL = @"http://localhost:8888/Insert.php";
NSURL *url = [NSURL URLWithString:strURL];
NSMutableURLRequest *req = [[NSMutableURLRequest alloc]initWithURL:url];
[req setHTTPBody:data];
[req setHTTPMethod:@"POST"];
NSURLConnection *con = [NSURLConnection connectionWithRequest:req delegate:self];
}
웹 서비스에 대한 스크립트 : 나는 PHPAdmin 페이지에서 내 응용 프로그램을 실행하면
<?php
$host = 'localhost';
$username = 'root';
$password = 'root';
$con = mysql_connect($host, $username, $password);
if(!$con)
{
echo "Failed connection";
echo "<br/>";
die('Connection failed');
}
mysql_select_db("unbounded", $con);
$ids = $_GET['id'];
$str = $_GET['input'];
$in= mysql_query("INSERT INTO `unbounded`.`stuff` (`id`, `string`) VALUES ('$ids','$str');");
echo $in;
echo "<br/>";
mysql_close($con);
?>
내가 그 id 값이 0 때마다로 설정되어 볼 수 있습니다 I 문자열 값이 비어있는 동안 앱을 실행하십시오.
브라우저를 통해 스크립트를 실행하면 데이터를 잘 삽입 할 수 있습니다. 그런데 일단 스크립트 vi 브라우저를 실행하면 DB와의 연결이 잘 이루어 졌음을 발견했습니다. . 문제의 원인은 무엇입니까? 최고의 regrads 당신의 아이폰 OS에서
그리고 당신은 아주 옳습니다. 고마워! – uml