Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 11th Dec 2011, 04:42 AM   #1
Active Warrior
 
Amsterdam's Avatar
 
Join Date: 2005
Location: Wirral, UK
Posts: 66
Thanks: 2
Thanked 6 Times in 5 Posts
Default
Put link into variable? PHP
Share on: 
fb share twitter share gplus share more share

Hi,

I'm trying to add a paused re-direct to a page using:

Code:
echo '<META HTTP-EQUIV="Refresh" Content="3; URL=$mylink">';
But whenever I give the variable '$mylink' a value such as 'www.warriorforum.com' it won't read the value and tries to re-direct to $mylink instead.

What am I doing wrong?

T
Amsterdam is offline  
Unread 11th Dec 2011, 05:07 AM   #2
HyperActive Warrior
War Room Member
 
Nikolas's Avatar
 
Join Date: 2007
Location: Greece
Posts: 159
Thanks: 11
Thanked 31 Times in 29 Posts
Default
Re: Put link into variable? PHP
Share on: 
fb share twitter share gplus share more share

Php wont parse variables in this kind of bracket. Here is the right way:

echo '<META HTTP-EQUIV="Refresh" Content="3; URL=' . $mylink . '">';

Last edited on 11th Dec 2011 at 05:08 AM. Reason: wrote wrong the code
Nikolas is offline  
The Following User Says Thank You to Nikolas For This Useful Post:
Unread 11th Dec 2011, 07:00 AM   #3
Night Angel
 
hhunt's Avatar
 
Join Date: 2009
Location: Underground
Posts: 158
Thanks: 2
Thanked 14 Times in 14 Posts
Default
Re: Put link into variable? PHP
Share on: 
fb share twitter share gplus share more share

Not sure what you're doing wrong, if you could post your code that should help narrow down the problem.

hhunt is offline  
Unread 11th Dec 2011, 08:32 PM   #4
Warrior Member
 
Join Date: 2011
Location: Cleveland
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Re: Put link into variable? PHP
Share on: 
fb share twitter share gplus share more share

Nik. is correct. Echos wrapped in single quotes will not interpret. Do what he said or wrap the echo in double quotes so it interprets variables. I am on my DROID or I would post a snippet.

Play bocce? Check out our cool selection of Bocce Ball Sets or the only drink koozie that keeps score!
bocceman is offline  
Unread 12th Dec 2011, 06:13 AM   #5
HyperActive Warrior
War Room Member
 
Join Date: 2002
Location: United States
Posts: 421
Thanks: 22
Thanked 98 Times in 74 Posts
Default
Re: Put link into variable? PHP
Share on: 
fb share twitter share gplus share more share

If the variable is set do this:


echo "<META HTTP-EQUIV=\"Refresh\" Content=\"3; URL=$mylink\">";

OR

echo "<META HTTP-EQUIV=\"Refresh" Content=\"3; URL=".$mylink."\">";
Terry Crim is offline  
Unread 12th Dec 2011, 12:22 PM   #6
Quality > Quantity
War Room Member
 
Join Date: 2011
Location: Germany
Posts: 67
Thanks: 2
Thanked 8 Times in 8 Posts
Default
Re: Put link into variable? PHP
Share on: 
fb share twitter share gplus share more share

Hello Amsterdam,

Your problem is that you used ' instead of " after echo. With ' php will not parse variables in the string while in " it will.
So your correct syntax would be
echo "<META HTTP-EQUIV= \"Refresh\" Content=\"3; URL=$mylink\">";

Of course you need to escape " in the code then.

Hope that helped you.

Greetings
SeeSharp is offline  
Closed Thread


Bookmarks

Tags
link, php, put, variable


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 05:32 AM.