I am creating an application that requires to insert a row into a mysql database (hosted on the Internet), however whenever I try to insert data, the data is empty. there is nothing wrong with php since my web interface works fine with php script.
NSString *user = self.registerUsername.text; NSString *password = self.registerPassword.text; NSString *email = self.registerEmail.text; NSString *model = [NSString stringWithFormat:@"%@", [[UIDevice currentDevice] model]]; NSString *sysVer = [NSString stringWithFormat:@"%@", [[UIDevice currentDevice] systemVersion]]; NSString *connectionURL = @"mydomain.com/Register.php"; NSLog(@"%@", connectionURL);
mRegister.php
<?php header('Content-type: text/plain; charset=utf-8'); include("config/dp.php"); //<- db connection $con = mysql_connect("127.0.0.1","user","pass"); if(! $con) { die('Connection Failed'.mysql_error()); } mysql_select_db("hk", $con); $message = ""; $username = ($_POST['username']); $password = ($_POST['password']); $email = ($_POST['email']); $model = ($_POST['model']); $sysver = ($_POST['sysver']); $submit = $_POST["registerform"]; $sql = "INSERT INTO members (`username`, `password`, `email`, `model`, `sysver`) VALUES ('$username', '$password', '$email', '$model', '$sysver')"; $result = mysql_query($sql); $row = mysql_fetch_array($result); if ($result) { $message = "success"; } else { $message = "failed"; } echo utf8_encode($message); ?>
also, responseString usually appears with some strange characters after it affects the value of responseString.length . Is something wrong with my code or is it related to my php?
source share