[PHP] question on parameter specification in href tag

2008-12-12 Thread Xaver Thum
Hi,

I want to set a link like

a href=http://www.anyurl.com?mypar=17color=red; ...

into my HTML file; that works fine.

But if I specify a hex color like #CC instead of red,

a href=http://www.anyurl.com?mypar=17color=#CC; ...

the color is ignored (probably because # starts a PHP comment).
Is there any workaround for this problem ?

Thanks and Regards

 Xaver 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] question on parameter specification in href tag

2008-12-12 Thread Robert Cummings
On Thu, 2008-12-11 at 11:30 +0100, Xaver Thum wrote:
 Hi,
 
 I want to set a link like
 
 a href=http://www.anyurl.com?mypar=17color=red; ...
 
 into my HTML file; that works fine.
 
 But if I specify a hex color like #CC instead of red,
 
 a href=http://www.anyurl.com?mypar=17color=#CC; ...
 
 the color is ignored (probably because # starts a PHP comment).
 Is there any workaround for this problem ?
 
 Thanks and Regards

urlencode()

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] question on parameter specification in href tag

2008-12-12 Thread Daniel Brown
On Thu, Dec 11, 2008 at 05:30, Xaver Thum xaver.t...@t-online.de wrote:

 But if I specify a hex color like #CC instead of red,

 a href=http://www.anyurl.com?mypar=17color=#CC; ...

 the color is ignored (probably because # starts a PHP comment).
 Is there any workaround for this problem ?

Hey, X;

Actually, it's skipped because it's seen as a page anchor.  That's
a client-side only thing, and the browser would then be looking for:

a name=CC id=CC/a

Instead, skip the hashmark:

a href=http://www.anyurl.com/?mypar=17color=CC; ...

 and have it parsed similarly to this:

?php
if(strlen($_GET['color']) == 6 
preg_match('/[a-f0-9]{6}/i',trim($_GET['color']))) {
// Color is a legitimate HTML hexadecimal color
$_GET['color'] = strtoupper($_GET['color']); // Set upper-case
} else {
// Color is not legit, was not supplied, or this may be a lame
hack attempt
$_GET['color'] = 'CC'; // Force default color
}

$color = '#'.$_GET['color'];
?

-- 
/Daniel P. Brown
http://www.parasane.net/
daniel.br...@parasane.net || danbr...@php.net
50% Off Hosting! http://www.pilotpig.net/specials.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php