Page 1 of 1

PHP newbie - question about variables

Posted: Fri Jul 14, 2006 10:20 am
by packie
Hi,

I'm just starting on PHP and I have a problem passing a variable.
Here is the code that is not working for me.

Code: Select all

$selected = "test";
                                         <a href=testvar.php?passedvar=$selected><img src="gifs/go.gif" alt="" name="" width="30" height="20" border="0"></a>


The testvar.php page has the following code

Code: Select all

<?php
echo $_GET['passedvar'];
?>
I'm trying to get the output from the echo to be test, but at the moment all that is being outputted is $selected
Am I missing something obvious?

Thanks,

Posted: Fri Jul 14, 2006 10:28 am
by dull1554
to output html or anything you have to call a method to output it to the screen i.e. echo or print

example

Code: Select all

<?php
$selected = "test";
echo "<a href=testvar.php?passedvar=$selected><img src='gifs/go.gif' alt='' name='' width='30' height='20' border='0'></a>";
?>