I have a strange problem. I recently migrated my application from my local xampp installation to a SUSE Enterprise Server 11 and everything is working but this one thing drives me crazy and I can't find a solution.
When passing arrays either through GET or POST using this syntax:
search_dggs.php?latmin[]=52.447529&latmin[]=22&lonmin=17.56&lonmax=22.16
I only get the first element of latmin. Mind you that this is only a simple example I tried after the error occurred in other places where the passing of arrays is necessary.
print_r($_SERVER["QUERY_STRING"]);
outputs
latmin[]=52.447529&latmin[]=22&lonmin=17.56&lonmax=22.16
but
print_r($_GET);
gives
Array
(
[latmin] => Array
(
[0] => 52.447529
)
[lonmin] => 17.56
[lonmax] => 22.16
)
Exactly the same happens with all POST requests.
I'm using PHP Version 5.3.8. I guess the problem is some Server configuration but I couldn't find anything about this problem.
Response to comments:
The same happens if I submit any number of variables.
parse_str($_SERVER["QUERY_STRING"]);
print_r($latmin);
gives
Array
(
[0] => 52.447529
)
php.ini can be found here
You should be able to see the behaviour in action here
The source file of this php file is
<?php
$test="latmin[]=52.447529&latmin[]=22&lonmin=23&lonmax=22.16";
parse_str($test);
print_r($latmin);
phpinfo();
?>
Well my System Admin did a system update and reboot and the issue is now fixed. No configuration files were changed.
Tested on my server and it works fine for me:
_GET["latmin"]
Array
(
[0] => 52.447529
[1] => 22
)
Look in your php.ini in the Data Handling section and see what the values are. Reset everything to default, restart the webserver and try again. PHP.ini Data Handling defaults
An example at the link prints Array ( [0] => 52.447529 )
every time even no variables were passed. So, seems that you have problem in code that is not linked with this code:
`
$test="latmin[]=52.447529&latmin[]=22&lonmin=23&lonmax=22.16";
parse_str($test);
print_r($latmin);
phpinfo();
`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With