i am sending data from iphone to server using php it is sending data from iphone but not inserting in mysql i am using following php code.
<?php
$con =
mysql_connect("surveyipad.db.6420177.hostedresource.com","tom","ben");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("surveyipad", $con);
$device_Id=$_POST['device_Id'];
$R1=$_POST['R1'];
$R2=$_POST['R2'];
$R3=$_POST['R3'];
$comment=$_POST['comment'];
$update_date_time=$_POST['update_date_time'];
$query=("INSERT INTO survey_responsese_pfizer (device_Id,R1,R2,R3,comment,update_date_time)
VALUES ('$device_Id','$R1','$R2','$R3','$comment','$update_date_time')");
mysql_query($query,$con);
printf("Records inserted: %d\n", mysql_affected_rows());
echo($device_Id)
?>
echo($device_Id)? you also have sql-injection, you should escape inputs else adding'to one of your parameters will break the query...mysql_error(), to see if there was some sort of error and post it heresprintffor example. Also, be on your guard for user input, it may be false.Mysql_real_escape_stringwill be needed on your$_POSTvalues and - as @zan said - go have a look at PDO. Sidenote: the use ofdie()is something not needed here, use propper error handling in stead