Solved

Php header...

Posted on 2011-02-27
4
243 Views
Last Modified: 2012-05-11
Any ideas why it will not accept my variable as variable. It thinks it is a string value.


// The link is variable depending on the page.
$txnlink = http://www.google.com;

header('Refresh: 4; URL =$txnlink');

Open in new window

0
Comment
Question by:blink10
  • 2
4 Comments
 
LVL 16

Expert Comment

by:santoshmotwani
ID: 34990948
// The link is variable depending on the page.
$txnlink = "http://www.google.com";

header('Refresh: 4; URL =$txnlink');
0
 
LVL 4

Accepted Solution

by:
LAMASE earned 500 total points
ID: 34991019
You are using single quotes
header('Refresh: 4; URL =$txnlink');

Open in new window


for have the variable parsed you should use double quotes,
header("Refresh: 4; URL =$txnlink");

Open in new window

or string concatenation
header('Refresh: 4; URL ='.$txnlink);

Open in new window

0
 
LVL 4

Expert Comment

by:LAMASE
ID: 34991066
Ah, and you use quotes in the other string, too

$txnlink = "http://www.google.com";

Open in new window

0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 34991752
Here is the man page about string definitions.  You really want to read this and understand the syntax completely.
http://www.php.net/manual/en/language.types.string.php

Here is the man page about the header() function. Whenever you are not 100% sure what a PHP function does, you can find the function documentation online.  Take note of the very common error about the use of header() after browser output has already occurred.  Even invisible whitespace can cause problems for your script.
http://us2.php.net/manual/en/function.header.php

It looks like you mean to cause the client browser to refresh and redirect to Google after 4 seconds.  You can do this, of course, but from a UX standpoint, I think I would ask myself if this is really a good thing for the client.  What will they see on the screen for 4 seconds?  Is 4 seconds a sensible length of time to display this information?  What can a client do with the information that will disappear after 4 seconds?  You might want to ask yourself, is it really necessary to display this at all?
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article discusses how to create an extensible mechanism for linked drop downs.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now