Page 1 of 1

Linking with variables

Posted: Fri Jun 21, 2002 4:05 pm
by ibelimb
Hey, this must be my like 5th post today!

I'm trying to link to another page, and i need a variable insie the href= and i cant seem to do it. Im trying ot put it inside a echo ' '; that contains other lines of HTML code to, but i cant seem to get $session to show the session id. instead PHP puts the link out like login3.php?$session and thats not how i want it, i want the session id, i have $session assigned with session_id(); so its not that.

I've tried other things too but thsoe have failed. How do i fo it?

Thanks,
Limb

Posted: Fri Jun 21, 2002 4:41 pm
by gxpark
use the string concatenation operator (a dot) or use a change single quotes to double quotes, or viceversa :) it always confuses me which one automatically changes variable names for their values (I'm used to use concatenation operators like in most other languages).

Posted: Fri Jun 21, 2002 4:43 pm
by will
I'm going to guess you are doing echo'' (with single quotes) and not echo"" with double quotes. if that is the case, then you need to understand that the variable is not converted to its value with the single quotes....you'll need to do string concatenation.... here are two possible solutions...

Code: Select all

//use single quotes, and concatenate  (preferred)
echo 'login3.php?'.$session;

//use double quotes
echo "login3.php?$session";
a good article on the subject can be found at http://www.webmasterbase.com/article/686

Posted: Fri Jun 21, 2002 4:56 pm
by ibelimb
Ahh got it working, thansk i had them in ' ' not " ". Now it works, thanks!