Ask a Question related to PHP Development, Design and Development.
-
Magnus Warker #1
ampersand problem when passing multiple parameters in URL
Hi,
when I try to pass some parameters in an URL, I always get an URL where the
ampersand is represented as '&'.
I tried:
$url = "wsp.php?mod=$mod&sec=$sym";
$url = "wsp.php?mod=$mod" . '&' . "sec=$sym";
and many other variations.
The result is always the same (for $mod=adm and $sec=usr):
'wsp.php?mod=adm&sec=usr'
The ampersand seems to be masked by some unwanted functionality.
So, how can I get my URL as follows:
'wsp.php?mod=adm&sec=usr'
Thank you very much,
Magnus
Magnus Warker Guest
-
Passing Parameters To CFC
I am testing how to return data from a CFC within Flash Forms. I have a simple <cfselect> tag that will hold data returned from a CFC. This CFC... -
CFContent Problem - Passing parameters in URL with imgsrc tag
Hi All, My code is like this on the ViewImage.cfm page <img src="GetImage.cfm?id=123"> on the GetImage.cfm page <cfcontent type="image/gif"... -
passing parameters
Hi Michael, I think you want to modify the links in web control programmatically. You can add several Hyperlink controls to the user control,... -
Problem passing parameters usign DynaLib
Hi, I want to call functions that I have in dynamic library (written in C) from a perl program. I'll try it using the module DynaLib but I´m... -
Help Passing Parameters
Before going to the third script I'd suggest storing the variables in session variables. Here's how I generally do login scripts. Perhaps have... -
Tom Thackrey #2
Re: ampersand problem when passing multiple parameters in URL
On 4-Aug-2003, Magnus Warker <magnus@gmx.de> wrote:
The only way & would get changed to & is if you run the string through> when I try to pass some parameters in an URL, I always get an URL where
> the
> ampersand is represented as '&'.
>
> I tried:
>
> $url = "wsp.php?mod=$mod&sec=$sym";
> $url = "wsp.php?mod=$mod" . '&' . "sec=$sym";
>
> and many other variations.
>
> The result is always the same (for $mod=adm and $sec=usr):
>
> 'wsp.php?mod=adm&sec=usr'
>
> The ampersand seems to be masked by some unwanted functionality.
> So, how can I get my URL as follows:
>
> 'wsp.php?mod=adm&sec=usr'
htmlspecialchars() or a similar function. Post the code.
--
Tom Thackrey
[url]www.creative-light.com[/url]
Tom Thackrey Guest
-
matty #3
Re: ampersand problem when passing multiple parameters in URL
Magnus Warker wrote:
It's meant to be & if it's in an html page.> Hi,
>
> when I try to pass some parameters in an URL, I always get an URL where
> the ampersand is represented as '&'.
>
> I tried:
>
> $url = "wsp.php?mod=$mod&sec=$sym";
> $url = "wsp.php?mod=$mod" . '&' . "sec=$sym";
>
> and many other variations.
>
> The result is always the same (for $mod=adm and $sec=usr):
>
> 'wsp.php?mod=adm&sec=usr'
>
> The ampersand seems to be masked by some unwanted functionality.
> So, how can I get my URL as follows:
>
> 'wsp.php?mod=adm&sec=usr'
>
> Thank you very much,
> Magnus
--
Matt Mitchell - AskMeNoQuestions
Dynamic Website Development and Marketing
matty Guest
-
Magnus Warker #4
Re: ampersand problem when passing multiple parameters in URL
Hi Tom,
here is the code. The function should print a table item with a label ($lbl)
which is a link to a workspace ($wsp) containing two parameters, a module
($mod) and a section ($sym):
function mod_idx_itm ($mod,$sym,$lbl)
{
$url = "wsp.php?mod=$mod&sec=$sym";
print " <td align='left' nowrap>\n";
echo " <a href='" . "$url" . "'>$lbl</a>\n";
print " </td>\n";
}
Matty:
You mean, & in URLs is really correct and works??
Magnus
Tom Thackrey wrote:
> The only way & would get changed to & is if you run the string through
> htmlspecialchars() or a similar function. Post the code.
>Magnus Warker Guest
-
Chris Morris #5
Re: ampersand problem when passing multiple parameters in URL
Magnus Warker <magnus@gmx.de> writes:
It's *correct* if it's output to HTML for the browser to parse - so> You mean, & in URLs is really correct and works??
<a href="example.php?this=2&that=1">
or
<img src="exampleimage.php?this=2&that=1" alt=" ">
Works in every browser I've tested in (ranging from Mozilla 1.4 down
to Netscape 1) - not entity referencing the & to & is known to
break at times.
It's *not correct* if it's being used for internal purposes in PHP
header("Location: http://www.example.com/example.php?this=1&that=2");
or
include("http://www.example.com/example.php?this=1&that=2");
--
Chris
Chris Morris Guest
-
matty #6
Re: ampersand problem when passing multiple parameters in URL
Magnus Warker wrote:
If it's in an HTML page, yes! The urls are actually *meant* to be like this,>
> Matty:
> You mean, & in URLs is really correct and works??
>
> Magnus
>
>
and if they're not, they're actually invalid. If you're storing it in a database,
or sending an HTTP header, then no, it shouldn't be entity escaped.
$url='http://myserver.com/?this=that&me=you';
print '<a href="'.htmlentities($url).'">'; ...
but
header('Location: '.$url."\r\n");
HTH
matty Guest



Reply With Quote

