Forum Moderators: coopster

Message Too Old, No Replies

cant get simple script to work on php

         

kenfused

5:15 am on Aug 11, 2010 (gmt 0)

10+ Year Member



Help!

for this script


<? echo "oink is $foo";?>

I have saved it as poo.php

If I run the script www.mysite.com/poo.php?foo=oink
on one site I get : "oink is oink" which is what I am supposed to get, but on another server I am working on, the identical code and the URL I get
"oink is" so it does not seem to pass the string along
Help!

Matthew1980

7:48 am on Aug 11, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there Kenfused,

How many error's in a small snippet!

Firstly:-

Use full tags: <?php ?> this is supported by all servers, short tags: <? ?> are only used if the ini file explicitly says so, so for compatibility you need full tags, just in case you migrate your software :)

Secondly:-
Again, registered globals (using $foo as opposed to $_GET['foo'] or $_POST['foo']) need to be on if you want to use the $foo shortform - again, preferable to avoid this, again because the ini file server to server are usually different, avoid headaches :)

Check out: [php.net ] for more info

So your code would be:-
<?php
if (isset($_GET['foo'])){
echo "oink is ".$_GET['foo'];
}
else{
echo "Querystring is currently not set";
}
?>

You get the idea :)

Cheers,
MRb

kenfused

1:22 am on Aug 12, 2010 (gmt 0)

10+ Year Member



THanks!
Got it working with your help!
I'm just not very experienced!