Web Design Forum  
 
Go Back   Web Design Forum > Web Software > Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 08-28-2009, 10:13 AM   #1
New Member
 
Maxchen's Avatar
 
Join Date: Jul 2009
Posts: 22
Default php redirect syntax

Can any one help me with a little syntax problem i have.

Currently the code reads

PHP Code:
<?php
header
("location:http://www.website.com/$row_rbs_redirect['redirect']");
exit;
?>
where the last part of the url is gathered from a recordset. The problem is in this area but i don't know what's wrong with it. I just inserted the code from the bindings panned in DreamWeaver.

thank you!
Maxchen is offline   Reply With Quote


Old 08-30-2009, 12:26 PM   #2
New Member
 
Join Date: Aug 2009
Posts: 2
Default

you can't use a variable within a string... your variable $row_rbs_redirect['redirect'] is not interpreted as a variable, but as a normal string!
the correct version is:

PHP Code:
<?php
header
("location:http://www.website.com/".$row_rbs_redirect['redirect']);
exit;
?>
PrimaFacie is offline   Reply With Quote
Old 10-07-2009, 01:21 PM   #3
New Member
 
Jecht's Avatar
 
Join Date: Jul 2007
Location: Livorno, Italy
Posts: 5
Default

No, you can! For arrays, you can't just write 'em, you need some {} around instead. Honestly i find this way more convenient than PrimaFacie's solution. Just a matter of habits...
PHP Code:
<?php
header
("location:http://www.website.com/{$row_rbs_redirect['redirect']}");
exit;
?>
PS: works with not-arrays too
PHP Code:
<?php
echo "Bla bla bla {$myVar} bla bla";
?>
__________________
[SIGPIC][/SIGPIC]

Last edited by Jecht; 10-07-2009 at 01:23 PM.
Jecht is offline   Reply With Quote
Old 10-11-2009, 09:08 PM   #4
New Member
 
Maxchen's Avatar
 
Join Date: Jul 2009
Posts: 22
Default

Thank you all, problem solved!
Maxchen is offline   Reply With Quote
Reply

Tags
code, php, redirect, syntax

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 01:11 PM.


Camera Forum - Computer Forum - Web Design Forum

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO 3.6.0 ©2011, Crawlability, Inc.