my problem is this one, I have a javascript code that gets GPS location from a browser. Then, because I can’t write those coordinates to SQL database from javascript and I can’t send it directly to php, I go to the controller “site” and it’s method “writeToDatabase” and I also add 4 segments to URL that are actually those coordinates that I got from javascript..
so in javascript I have:
window.location = getBaseURL() + "site/writeToDatabase/" + splittedLatitude[0] + "/" + splittedLatitude[1]
+ "/" + splittedLongitude[0] + "/" + splittedLongitude[1] + "/";
so now the browser goes to (just an example with fake coordinates) http://www.mysite.com/index.php/site/writeToDatabase/47/707223/16/054322
now my writeToDatabase method in site controller reads those segments (I use codeigniter so it is really easy to read segments of URL). After I read segments, I concat first part of latitude and second part of latitude, and also put a dot “.” in between (so in this example I get 47.707223 and 16.54322), and I do the same with the longitude.. then when I write those data to database, I get weird numbers in my database, also if one of my segments begins with zero (just like in my example above), the zero gets removed so from 054322 I get 54322, and that leads to 16.54322 just like in the example above 🙂
now this problem with strange numbers only occurs if I try to write to database whole coordinates.. if I just write first part of longitude, or just second part of longitude (same goes for latitude) everything goes well and correct value gets written..
anyone else has a solution to this problem? I’m all out of ideas
Why don’t you just send the parameters as they are like this:
That does fix that issue.
However you can do it your way (since these are strings not integers) with simple string concatenation like this.