473,322 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

redirect

Hi,

What's wrong with that?

I have a variable

$order_nummer = "C.45";

Then I redirect to

header('Location: xmlorderon.php?order_id=$order_nummer');

but I my location bar I see:

http://localhost/pcGebruik/files/xmlorderon.php?order_id=$order_nummer
thx
Alain
Jul 17 '05 #1
5 3084
Use double quotes instead.
" instead of ' in your header argument.
On Wed, 4 Feb 2004 11:24:53 +0100, "alain dhaene"
<a.******@instruct.be> wrote:
Hi,

What's wrong with that?

I have a variable

$order_nummer = "C.45";

Then I redirect to

header('Location: xmlorderon.php?order_id=$order_nummer');

but I my location bar I see:

http://localhost/pcGebruik/files/xmlorderon.php?order_id=$order_nummer
thx
Alain


Jul 17 '05 #2
alain dhaene wrote:
I have a variable

$order_nummer = "C.45";

Then I redirect to

header('Location: xmlorderon.php?order_id=$order_nummer');

but I my location bar I see:

http://localhost/pcGebruik/files/xmlorderon.php?order_id=$order_nummer


The contents of single quotes are taken literally (with two exceptions).

echo 'the variable a holds $a'; // taken literally
echo 'it\'s a exception'; // the \' is taken as a single '
echo 'the other exception is \\ a single backslash';
So to have your header() do what you want either use double quotes
(which interpolate much more than single quotes) or concatenate the
contents of $order_nummer to the rest of the URL:

header('Location: xmlorderon.php?order_id=' . $order_nummer);

Better yet is to use urlencode() for the $order_nummer:

header('Location: xmlorderon.php?order_id=' . urlencode($order_nummer));
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #3
Pedro Graca <he****@hotpop.com> schrieb:
Better yet is to use urlencode() for the $order_nummer:

header('Location: xmlorderon.php?order_id=' . urlencode($order_nummer));


And even better would be the use of a valid syntax for the location.

header('Location: http://www.example.com/xmlorderon.php?order_id=' .
urlencode($order_nummer));

According to http://www.php.net/manual/en/function.header.php HTTP/1.1
requires an absolute URI as argument to Location: including the scheme,
hostname and absolute path, but some clients accept relative URIs. So
with the short version it might work on some clients and fail on others
and that's not what you want. :-) Use the correct version and it will
run anywhere.

Regards,
Matthias
Jul 17 '05 #4
Matthias Esken wrote:
And even better would be the use of a valid syntax for the location.

header('Location: http://www.example.com/xmlorderon.php?order_id=' .
urlencode($order_nummer));


Right. Thank you for the correction.

The W3C (World Wide Web Consortium) says the same thing about the
Location: header:
http://www.w3.org/Protocols/rfc2616/....html#sec14.30
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #5
Pedro Graca wrote:
Right. Thank you for the correction.


Where it is written "correction", please read "revision and update"
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Bob Garbados | last post by:
forgive my ignorance, as I'm new to php coming from a ms background... If I create a page named redirect.php and it's only content is: <?php header("Location: http://www.google.com"); ?>...
3
by: Paul | last post by:
I'm not getting the results I want when I use Response.Redirct in a ASP page. I enter this line of code in a asp page from domain1.com. Response.Redirect...
7
by: Donna Hawkins | last post by:
I want to use javascript to redirect to a URL which has been passed as a variable (in php). I have searched but cannot find any solution. I think this code is a basic redirect: <script...
1
by: Peter Kirk | last post by:
Hi there I have a program written by another company (it's a "web control" which returns a web-page: can I compare this to a servlet in the Java world?), which they think is causing problems on...
2
by: Mark Dengler | last post by:
Is it possible to do a Response.Redirect to multiple URLs? I have tried the following and it simply ignores the first redirect: Response.Redirect("test.aspx", false);...
3
by: Justin | last post by:
Hi, Im confused here over the usage of Response.Redirect and Server.Transfer. I used frameset for my work, what are the proper usages of the two methods that seems working similar.. The...
6
by: Sam | last post by:
I have some issues with HTTP Headers and I was hoping for some pointers or references to good articles. Here is the problem. I have 6 .aspx pages, each page contains a common .ascx. This ascx...
6
by: Peter Row | last post by:
Hi, I am writing a DLL in VB.NET that implements IHttpHandler.ProcessRequest. This code calls a sub and I need to know if that sub did a response redirect or not. Specifically I need to know...
5
by: venner | last post by:
I'm having an issue with an ASP.NET website after upgrading to ASP.NET 2.0. The website makes use of a central authentication service (CAS) provided at the university I work for. Each page checks...
10
by: Eirik Eldorsen | last post by:
How can I 301 redirect www.example.com/default.aspx to www.example.com without using ISAPI filters?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.