| 
	
 | 
 Posted by Jack Jackson on 06/05/05 17:17 
Thanks! 
 
Leon Poon wrote: 
> The simplest way to make sure everything work well regardless of what  
> the values are: 
>  
> <? 
> $url = "somepage.php?var1=".urlencode($var1)."&var2=".urlencode($var2); 
> echo "<a href=\"".htmlspecialchars($url)."\">"; 
> ?> 
>  
> htmlspecialchars() changes characters '&', '"', ''', '<', '>' into the  
> HTML equivilant. And yup, you should do this for all *ML pages as long  
> as the thing being printed is not part of the mark-up syntax. 
>  
>  
>  
> Jack Jackson wrote:> 
>  
>> Rory Browne wrote: 
>> 
>>> On 6/4/05, Jack Jackson <jackson.linux@gmail.com> wrote: 
>>> 
>>>> Hi, Rory 
>>>> 
>>>> Rory Browne wrote: 
>>>> 
>>>>> I think you have the idea. The &'s are used to seperate the various 
>>>>> variables. If you want to set $p to something like 'Tom & Jerry' then 
>>>>> personally I'd do something like: 
>>>>> 
>>>>> <?php 
>>>>> 
>>>>> $p = "Tom & Jerry"; 
>>>>> $s = "Cat & Mouse"; 
>>>>> printf("<a href='{$_SERVER['PHP_SELF']}?p=%s&s=%s", urlencode($p), 
>>>>> urlencode($s)); 
>>>>> 
>>>>> ?> 
>>>>> 
>>>> That's nice. To get more specific (because my code varies a bit from 
>>>> yours and I don't wanna mess up the ) and ' and " s: 
>>>> $p and $c are actually row ID numbers so up to 3 digits. So for  
>>>> example if 
>>>> 
>>>> $p=1 
>>>> $c=32 
>>>> 
>>>> I was wanting to see a URL of 
>>>> 
>>>> http://foo.com?r=1&c=32 
>>>> 
>>> 
>>> In that case, you can simply echo them out, once you're sure that $r, 
>>> and $c are actually integers. 
>> 
>> 
>> I forgot to mention that above I did $r = intval($_GET[r]) 
>> 
>> ! 
>> 
>> 
>> 
>> Thanks, everyone! 
>> 
>>> echo "<a href='http://foo.com?r=$r&c=$c'>whatever</a>" 
>>> 
>>> if not(sure they're integers, you could always 
>>> printf("<a href=\"http://foo.com?r=%d&c=%d\">whatever</a>", $r, $c); 
>>> 
>>> Alternatively you could $r = (int)$r; 
>>> 
>>> or echo "<a href='http://foo.com?r=" . (int)$r . "&c=" . (int)$c . 
>>> "'>whatever</a>"; 
>>> 
>>> There's more than one way to do it....... 
>>> 
>>>> so was this the way to go? 
>>>> 
>>>> 
>>>>     //Make a thumbnail table of contents to display in the left sidebar 
>>>> 
>>>>     while ($sidebar = mysql_fetch_assoc($sidebar_result)) { 
>>>>            $sidebar_thumbnails[] = "<a class='img-link' 
>>>> href='{$_SERVER['PHP_SELF']}?p=%p&c={$sidebar['art_id']},  
>>>> urlencode($p)' 
>>>> title=\"{$sidebar['art_title']}\"><img class='sidebar-img' 
>>>> src='{$image_dir}{$sidebar['art_thumbnail']}' width='50' height='60' 
>>>> border='0' alt=\"{$sidebar['art_title']}\" /></a>"; 
>>>>   } 
>>>> 
>>>> ? 
>>>> 
>>>> Thanks in advance! 
>>>> 
>>>> 
>>>> 
>>>>> On 6/4/05, Jack Jackson <jackson.linux@gmail.com> wrote: 
>>>>> 
>>>>> 
>>>>>> Hi, 
>>>>>> 
>>>>>> If I want to make a link to a URL which includes some GETs can I  
>>>>>> just do: 
>>>>>> 
>>>>>> <a href='{$_SERVER['PHP_SELF']}?p={$p}&c={$s}' ... etc etc 
>>>>>> 
>>>>>> or must I escape the ampersand somehow? 
>>>>>> 
>>>>>> TIA, 
>>>>>> --Jack 
>>>>>> 
>>>>>> --  
>>>>>> PHP General Mailing List (http://www.php.net/) 
>>>>>> To unsubscribe, visit: http://www.php.net/unsub.php 
>>>>>> 
>>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>> --  
>>>> PHP General Mailing List (http://www.php.net/) 
>>>> To unsubscribe, visit: http://www.php.net/unsub.php 
>>>> 
>>>> 
>>> 
>>> 
>>> 
>> 
>> --  
>> PHP General Mailing List (http://www.php.net/) 
>> To unsubscribe, visit: http://www.php.net/unsub.php 
>> 
>> 
>
 
[Back to original message] 
 |