0

Hi all, can someone tell me why I am unable to concatinate the variable $id to the members.php ?

Its driving me mad. . .

$id = $row["id"];

        	        $_SESSION['SESS_MEMBER_ID'] = $id;		   
		   	setcookie("id", $id, time()+86400);
							
			$securecode = $row["securecode"];
			$_SESSION['SESS_SECURE_CODE'] = $securecode;
			setcookie("securecode", $securecode, time()+86400);
			
			$creff = $row["creff"];
			$_SESSION['SESS_CREFF'] = $creff;
			setcookie("creff", $creff, time()+86400);
			
		/*
		Login and go to members area											
		*/
		//header("location: members.php?id=" ' .$_SESSION['id']. ');
		//header("Location: members.php?id=$id");
		//  
		//header("Location: members.php?id= ' .$_SESSION['SESS_MEMBER_ID']. '")
		//securecode.php?id=
		//header("Location: members.php?id='.id.'");
		//header("Location: members.php?id=$id");
		header("Location: members.php?id=<? print '.$id ?>");
2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Biiim
0
header("Location: members.php?id={$id}");
//or
header("Location: members.php?id=".$id);

header is a php command and is already inside php tags so there is no need to use php tags again, it's like playing with a string such as echo "members.php?id=$myvar";

String help:

strings in php are opened with a single or double quote, once opened they need to be ended with the same type quote and can be concatenated with a .

eg.

echo "hello ".$name."!";
echo 'hello '.$name."!";
echo 'hello '.$name.'!';
echo "hello {$name}!";
//all output
//hello Biiim!

note single quotes do not get special processing:

echo 'hello {$name}!\r\n';
//will print out exactly
//hello {$name}!\r\n

where as

echo "hello {$name}!\r\n";
//will print out hello Biiim!
// <- newline

you can escape characters in a string using a backslash eg.

echo "hello \"{$name}\"!";
//will print out 
//hello "Biiim"!

Edited by Biiim: php string usage guide

0

Infact your second header commented out should of worked:

//header("Location: members.php?id=$id");

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.