Thanks. That did it. What I came up with is:
echo "<a
pe=$row[3]\"><img alt=\"Edit\" src=\"images/edit.gif\" height=\"24\"
width=\"24\" border=\"0\" /></a>";

Is this fundamentally flawed? You mentioned " probably invalid in
itself, but we'll come to that." Were you referring to the space or the
whole pasing of array variables in an URL. I'm trying to come up with a
simple Edit form (custmaint.php) with a list of customers below the form.
When you click on the edit.gif it links to itself ($PHP_SELF really). I've
actually come a long way since I've started scripting in PHP, but would
appreciate any pointers.

Thanks for pointing me in the right direction!

Mike Smith

-----Original Message-----
From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 13, 2002 4:22 AM
To: 'Mike Smith'; PHP General
Subject: RE: [PHP] Escaping '#' Sign

> -----Original Message-----
> From: Mike Smith [mailto:[EMAIL PROTECTED]]
> Sent: 12 December 2002 14:47
> Rendered results of <a href...> =
> T/T #29&type=OEM
> id is the record id
> class is Null so that's OK.
> cust=company T/T #29
> type=OEM
> I present the info in a form...
> echo "<td>\n";
> echo "<input type=\"text\" name=\"cust\" value=\"$cust\">\n";
> echo "</td>\n";
> This gives me:
> +------------------------+
> |company T/T             |
> +------------------------+
> *Note lack of #29 which I do see in the HTML table. If I save 
> id=$id) this record cust will now be company T/T
> All the other fields fill in correctly. Is it seeing the # as 
> a comment?

Nope -- as an anchor name.  Written like this, you're telling your browser
to load the page identified by T/T (which, by
the way, is probably invalid in itself, but we'll come to that!), and then
go to the anchor named 29&type=OEM on that page.

What you need to do is urlencode() the value of the cust parameter before
inserting it in your <A href=....> tag, so that any characters which might
cause problems (such as # or &, or even space) don't appear in the rendered
URL, but instead are encoded as a %xx value (or maybe + for a space -- can't
remember which urlencode() does).  This is all you need to do -- as it's a
URL, it automatically gets URL-decoded by the Web server before being passed
to your script, so you should see what you want.  (But don't forget to
re-urlencode it if you need to pass it on in another URL!)

Hope this helps!

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to