Forum Moderators: coopster
<?php if($_SESSION['user']!= admin) { echo "<a href=\"userprofile.php?userID=<?php echo ($query['userID']);?>\">User</a>"; }?>
i have an error message which indicates the code's line as "Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING"
how can i a php code inside an echo tag?
Drogyn's suggestion would work too, but it's not quite as clean.
However, Russell's example might not work for you because, when your variable is an element of an array, you need to concatinate it like this:
echo "<a href=\"userprofile.php?userID=".$quer['userID']."\">User</a>";
...note that the variable is inside of ". and ."
Or you can put the variable in {} like:
echo "<a href=\"userprofile.php?userID={$quer['userID']}\">User</a>"; But the way Russel showed you would work if you were using a simple variable like:
echo "<a href=\"userprofile.php?userID=$userID\">User</a>";
I hope this helps,
Salsa
_______