Derick Rethans wrote:
> Jonathan Rosenberg wrote:
>> I have a page with thumbnail pictures that can be clicked on to see
>> a larger picture.  Each picture is hyperlinked as follows
>> <a HREF="show_pic.php?pic=blah&caption=Some+Text">
>> I access the 'pic' & 'caption' attributes with $_GET['pic'], etc.
>> Pretty standard stuff.
>> I have PHP set up so that error messages get mailed to a specified
>> mail account.  Every so often I get the following error message:
>> Undefined index:  caption
>> In file /home/..../show_pic.php, line 64
>> page: /show_pic.php?pic=gb3.jpg&amp;caption=Some+Text
>> The problem is obviously (I think) that the $_GET['caption'] is
>> failing.

True, if you receive &amp;caption in your URL, then the variable won't be
called $_GET['caption'], but $_GET['amp;caption'], which (I think) is
invalid because of the ;.

>> What I can't figure out is why the '&' got turned into '&amp;'.  Is a
>> browser doing this?

> Yes it is.

No, it isn't. I sure hope there is no browser which turns & in &amp; in
URL's. That would be very, very bad indeed!

> Actually, you should specify the URL with the &amp;
> yourself, like this:
> <a HREF="show_pic.php?pic=blah&amp;caption=Some+Text">

Of course not...this is a HREF tag, which can use & instead of &amp;. &amp;
is for displaying purposes only, not for URL's.

Following the tip from Marek, adjust your errormessage mailing thingy...add
all the $_GET variables to it (print_r($_GET)). Some other notices maybe
usefull to...


PHP General Mailing List (
To unsubscribe, visit:

Reply via email to