Welcome Guest, Not a member yet? Register   Sign In
can't write strings to database
#6

[eluser]illuzionist[/eluser]
there is something wrong with trying to cast those numbers to string..
now when I have url like this:
www.example.com/index.php/site/writeGPStoDatabase/?lat=45.7071587&lng=16.0575276

in writeGPStoDatabase method I do this:

Code:
$latitude = $_GET["lat"];
$longitude = $_GET["lng"];

$locationGPS = "Latitude: " + (string) $latitude + ", Longitude: " + (string) $longitude;

and when I echo out $locationGPS I get 61.7646863 which is actually those 2 numbers added together instead "Latitude: 45.7071587, Longitude: 16.0575276"
this realy confuses me, I thought I casted those values all to (string) when I created $locationGPS variable..


EDIT
omg what an obvious mistake that has been bothering me.. I'm juggling between javascript and php atm and I used javascript syntax to concat strings and used "+" character.. and in PHP you must use dot "." to concat strings.. unbelievable..


Messages In This Thread
can't write strings to database - by El Forum - 07-14-2012, 11:11 AM
can't write strings to database - by El Forum - 07-14-2012, 11:24 AM
can't write strings to database - by El Forum - 07-14-2012, 11:25 AM
can't write strings to database - by El Forum - 07-14-2012, 11:35 AM
can't write strings to database - by El Forum - 07-14-2012, 12:04 PM
can't write strings to database - by El Forum - 07-14-2012, 12:28 PM
can't write strings to database - by El Forum - 07-14-2012, 12:43 PM
can't write strings to database - by El Forum - 07-14-2012, 12:47 PM
can't write strings to database - by El Forum - 07-14-2012, 12:50 PM
can't write strings to database - by El Forum - 07-14-2012, 01:08 PM



Theme © iAndrew 2016 - Forum software by © MyBB