Hi guys,
I really need your help detecting an error.. this code runs fine without giving any exceptions, If tried query by query in the phpAdmin and also works fine, but when I run it from my Android device the orientation is inserted in the database, the position is inserted in the database, the new orientation id is set to the Service_Pic .. the only thing that doesn't works.. is setting the position id to the Service_Pic and I have no ideia why.. it works in phpadmin and it works with the orientation that has the same structure.. anyway I'll show you the code to make it clear:
<?php
mysql_connect("localhost", "root","root") or die(mysql_error()) ;
mysql_select_db("db") or die(mysql_error()) ;
// this values are retrieved from Android
$id = $_POST['id'];
$latitude = $_POST['latitude'];
$longitude = $_POST['longitude'];
$orientation = $_POST['orientation'];
// Insert new information
mysql_query("INSERT IGNORE INTO Orientation ( Orientation_ID, GPSImgDirection, GPSImgDirectionRef, Entries) VALUES ( '' , $orientation, '', 1) ");
$query1 = "SELECT Orientation_ID FROM Orientation WHERE GPSImgDirection=$orientation";
$result1=mysql_query($query1);
if (!$result1) {
echo 'Cant find orintation' . mysql_error();
exit;
}$row1=mysql_fetch_row($result1);
mysql_query("INSERT IGNORE INTO Position ( Position_ID, GPSLatitude, GPSLongitude, Entries, GPSLatitudeRef, GPSLongitudeRef) VALUES ( '' , $latitude, $longitude , 1 , '', '') ");
$query2 = "SELECT Position_ID FROM Position WHERE GPSLatitude=$latitude AND GPSLongitude=$longitude";
$result2=mysql_query($query2);
if (!$result2) {
echo 'Cant find position' . mysql_error();
exit;
}$row2=mysql_fetch_row($result2);
mysql_query("UPDATE Service_Pic SET Position_ID = $row2[0] WHERE ServicePic_ID=$id");
mysql_query("UPDATE Service_Pic SET Orientation_ID = $row1[0] WHERE ServicePic_ID=$id");
exit;
?>
I really hope it's just a silly mistake to get on with this.. thank you in advance