I cannot get my $_GET to work. It works on every other site I have on the server but just not on this site. The site is osCommerce and I am running PHP 5.
if (($HTTP_GET_VARS['image'] ==0) && ($products['products_image_lrg'] != '')) {
//do something
};
I also tried
echo $_GET['image']
and it still will not work. It just gives me undefined index.
The URL looks like this: /blah.php?image=2
I have stripped the page down to the bare still not working see below
<?php
echo $HTTP_GET_VARS['image'];
echo $_GET["image"];
echo "<br />";
?>
I get this
Notice: Undefined variable: HTTP_GET_VARS in \popup_image.php on line 3 Notice: Undefined index: image in \popup_image.php on line 4
I have been doing some more digging and it looks like a problem somewhere in oscommerce not allowing it to read
PHP $_GET is a PHP super global variable which is used to collect form data after submitting an HTML form with method="get". $_GET can also collect data sent in the URL.
There are two methods in PHP to collect data submitted in a FORM. GET Method and POST Method. In the GET method, you submit data from HTML FORM/collected using a super global variable $_GET. This method sends the encoded information from the FORM through the webpage URL.
You have forgotten to add the QSA (query string append) flag on your mod rewrite rule. Without this flag, any query string added to your url before the rewrite is discarded in favor of the new query string added to the rewrite rule, though it will still be visible in the bar at the top of the browser.
the following should work with PHP 5.x:
HTTP:
http://myserver/blah.php?image=2
PHP (blah.php?):
if (isset($_GET['image'])) { $idx=$_GET['image']; // Should be "2" }
I'm assuming you're trying to access "$_GET[]" from "blah.php". If not, you need to pass the URL to the page you're calling.
print_r($_GET)
or var_dump($_GET)
is a good idea. So is bumping error_reporting(NNN)
.
An even better idea is to create a dummy page, phpinfo.php:
phpinfo.php:
<?php phpinfo (); ?>
http query:
http://myserver/phpinfo.php?image=2
Q: Does phpquery() show you the "image" URL anywhere???
Finally, here's a similar case that turned out to be a PHP install problem:
First, try looking at an entire print out of the $_GET array:
print_r($_GET);
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