Connecting Tech Pros Worldwide Forums | Help | Site Map

Why won't variable echo?

affiliateian@gmail.com
Guest
 
Posts: n/a
#1: Oct 19 '06
Just moved web hosts and noticed that this:

<?php echo "$f"; ?>

used to work when there was an ?f= in the URL like so:
http://www.mydomain.com/index.html?f=yes

Now it doesn't at the new host.

I want to echo out "yes" in the HTML.

Any ideas?

TIA.


Chris Hope
Guest
 
Posts: n/a
#2: Oct 19 '06

re: Why won't variable echo?


affiliateian@gmail.com wrote:
Quote:
Just moved web hosts and noticed that this:
>
<?php echo "$f"; ?>
>
used to work when there was an ?f= in the URL like so:
http://www.mydomain.com/index.html?f=yes
>
Now it doesn't at the new host.
>
I want to echo out "yes" in the HTML.
>
Any ideas?
register_globals will be off on your new host.

Either enable it using .htaccess (if possible) or change all references
to eg echo $_GET['f']. The latter is the better option but if your site
is full of global references then as a short term solution you'll need
to get register_globals enabled.

More info here: http://nz.php.net/register_globals

--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
affiliateian@gmail.com
Guest
 
Posts: n/a
#3: Oct 19 '06

re: Why won't variable echo?


Chris Hope wrote:
Quote:
Either enable it using .htaccess (if possible) or change all references
to eg echo $_GET['f']. The latter is the better option but if your site
is full of global references then as a short term solution you'll need
to get register_globals enabled.
Thanks Chris, not sute how to enable register_globals but echo
$_GET['f'] worked! Thanks so much!

Rik
Guest
 
Posts: n/a
#4: Oct 19 '06

re: Why won't variable echo?


affiliateian@gmail.com wrote:
Quote:
Chris Hope wrote:
Quote:
>Either enable it using .htaccess (if possible) or change all
>references to eg echo $_GET['f']. The latter is the better option
>but if your site is full of global references then as a short term
>solution you'll need to get register_globals enabled.
>
Thanks Chris, not sute how to enable register_globals but echo
$_GET['f'] worked! Thanks so much!
Luckily.

Either make sure sure ALL your values are initialiased ($f = '' etc...),
or keep register_globals off (preferably both ofcourse), so your script
won't have to deal with variable values that have been set by a user on the
Evil Net, but only by youself, or a validated/checked request from the
user. That way you're reaonably sure what your sript does, instead of
intorducing unpredictable, and potentially harmfull, variables.
--
Rik Wasmus


aeg
Guest
 
Posts: n/a
#5: Oct 19 '06

re: Why won't variable echo?



affiliateian@gmail.com wrote:
Quote:
Just moved web hosts and noticed that this:
>
<?php echo "$f"; ?>
>
used to work when there was an ?f= in the URL like so:
http://www.mydomain.com/index.html?f=yes
>
Now it doesn't at the new host.
>
I want to echo out "yes" in the HTML.
>
Any ideas?
>
TIA.
Just at tip, for security reasons you may want to addslashes ie
addslashes($_GET['f]) else people could inject into your site.

Jerry Stuckle
Guest
 
Posts: n/a
#6: Oct 19 '06

re: Why won't variable echo?


aeg wrote:
Quote:
affiliateian@gmail.com wrote:
>
Quote:
>>Just moved web hosts and noticed that this:
>>
>><?php echo "$f"; ?>
>>
>>used to work when there was an ?f= in the URL like so:
>>http://www.mydomain.com/index.html?f=yes
>>
>>Now it doesn't at the new host.
>>
>>I want to echo out "yes" in the HTML.
>>
>>Any ideas?
>>
>>TIA.
>
>
Just at tip, for security reasons you may want to addslashes ie
addslashes($_GET['f]) else people could inject into your site.
>
Addslashes won't do a thing here - except maybe screwup the output he's
echoing.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Shelly
Guest
 
Posts: n/a
#7: Oct 19 '06

re: Why won't variable echo?



"Chris Hope" <blackhole@electrictoolbox.comwrote in message
news:4536c656@news.orcon.net.nz...
Quote:
affiliateian@gmail.com wrote:
>
Quote:
>Just moved web hosts and noticed that this:
>>
><?php echo "$f"; ?>
>>
>used to work when there was an ?f= in the URL like so:
>http://www.mydomain.com/index.html?f=yes
>>
>Now it doesn't at the new host.
>>
>I want to echo out "yes" in the HTML.
>>
>Any ideas?
I have made it a habit to always write something like that as:

<?php echo '"' . $f . '"'; ?>

or

<?php echo $f; ?>

and I always say <?php


(single-double-single quotes)

Shelly


aeg
Guest
 
Posts: n/a
#8: Oct 20 '06

re: Why won't variable echo?



Jerry Stuckle wrote:
Quote:
aeg wrote:
Quote:
affiliateian@gmail.com wrote:
Quote:
>Just moved web hosts and noticed that this:
>
><?php echo "$f"; ?>
>
>used to work when there was an ?f= in the URL like so:
>http://www.mydomain.com/index.html?f=yes
>
>Now it doesn't at the new host.
>
>I want to echo out "yes" in the HTML.
>
>Any ideas?
>
>TIA.

Just at tip, for security reasons you may want to addslashes ie
addslashes($_GET['f]) else people could inject into your site.
>
Addslashes won't do a thing here - except maybe screwup the output he's
echoing.
>
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
He's relying on data from the url though, this could be dangerous
unless processed correctly

Closed Thread