Forum Moderators: coopster

Message Too Old, No Replies

simple if statement or should be?

what am i doing wrong?

         

michaelbs

1:03 pm on Oct 26, 2004 (gmt 0)

10+ Year Member



I am trying to grab a value from the url then use it in an if statment like so

<?
$test= echo [$x];
if ($test > 40) {
echo "Yes, $test is greater than 40.";
}
?>

the url will be something like this

www.mydomain.com/test.php?x=56

but doest seem to work.

any ideas? this surely ist this hard

Birdman

1:46 pm on Oct 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When you assign a value to a variable, you shouldn't 'echo' it. Also, try to get in the habit of using the true variable name, rather than the short version. It's safer. Refer to GET vars like this: $_GET['x'] and if it were a posted form, it would be $_POST['x'].

<?
$test= $_GET['x'];
if ($test > 40) {
echo "Yes, $test is greater than 40.";
}
?>

Regards,
Birdman

michaelbs

2:09 pm on Oct 26, 2004 (gmt 0)

10+ Year Member



thanks Birdman! have a good day.