0

私は苦しめられてきました。なぜこのコードが機能しないのか理解できませんか? 私は何を間違えましたか?ありがとう、私は本当に助けが必要です

  <?php
$name = $POST['name'];
$tel = $POST['tel'];
$dbhost = "sql200.60ru.com"; 
$dbuser = "****"; 
$dbpassword = "***"; 
$dbname = "60ru_11939825_zav333"; 
$link = mysql_connect($dbhost, $dbuser, $dbpassword);
mysql_select_db($dbname, $link);
$query = "INSERT INTO customer (name, tel) VALUES (" . $name . "," . $tel . ")";
mysql_query($query, $link);
 mysql_close($link);
?>

NSString *bodyData =  @"fio=GGG&telefon=2521521551277777";    
    NSMutableURLRequest *postRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://zav333.60ru.com/test/insert.php"]];
    [postRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    [postRequest setHTTPMethod:@"POST"];
    [postRequest setHTTPBody:[NSData dataWithBytes:[bodyData UTF8String] length:[bodyData length]]];
    self.mainUrl = [[NSURLConnection alloc] initWithRequest:postRequest delegate:self];
4

1 に答える 1

1

これを変える

$name = $POST['name'];
$tel = $POST['tel'];

$name = $_POST['name'];
$tel = $_POST['tel'];

投稿値を取得するための正しい構文は$_POSTnot $POSTandです

$query = "INSERT INTO customer (name, tel) VALUES (" . $name . "," . $tel . ")";
mysql_query($query, $link);

$query = "INSERT INTO customer (name, tel) VALUES ('" . $name . "','" . $tel . "')";
mysql_query($query, $link) or die(mysql_error());
于 2012-12-18T06:30:27.707 に答える