0

I'm using the echo command in PHP, but I want to enter PHP code like <?php echo $variable [id_login]?>, while echoing something else out, but this does not work.

Is this possible to do, and if so, how would I do it?

echo "<script>location='member.php?&id=<?php echo $taruh[id_login] ?></script>";
Chris Forrence
  • 10,042
  • 11
  • 48
  • 64

1 Answers1

0

You cannot use echo or open/cloce php twice like you did, you might want to try something like the line below,

echo '<script>location=member.php?id=' . $taruh[id_login] . '</script>';

after echo you can write enything you'd like, even if it's a php variable, just use single quote and dot where you need it (like I do here), as you can see, echo is only used once..

For example:

<?php
$your_variable = 'some text';
$other_variable = 'some PHP code';
echo 'I wrote: ' . $your_variable . ' and ' . $other_variable . '&#33;';
?>

Output will be:

I wrote: some text and some PHP code!

I hope this will bring you into the right direction..

EDIT

Also important: if you use query string in URLs, the first 1 can be a ? every other part after should be a & for example see the url below

http://www.example.com/index.php?id=12345&coder=yes&country=usa

before id I used a quest sign, for all others I didn't use the quest sign...

jagb
  • 912
  • 11
  • 26