Connecting Tech Pros Worldwide Help | Site Map

Why won't variable echo?

 
LinkBack Thread Tools Search this Thread
  #1  
Old October 18th, 2006, 11:45 PM
affiliateian@gmail.com
Guest
 
Posts: n/a
Default Why won't variable echo?

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.


  #2  
Old October 19th, 2006, 12:05 AM
Chris Hope
Guest
 
Posts: n/a
Default 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
  #3  
Old October 19th, 2006, 01:25 AM
affiliateian@gmail.com
Guest
 
Posts: n/a
Default 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!

  #4  
Old October 19th, 2006, 04:05 AM
Rik
Guest
 
Posts: n/a
Default 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


  #5  
Old October 19th, 2006, 07:25 AM
aeg
Guest
 
Posts: n/a
Default 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.

  #6  
Old October 19th, 2006, 12:45 PM
Jerry Stuckle
Guest
 
Posts: n/a
Default 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
==================
  #7  
Old October 19th, 2006, 08:15 PM
Shelly
Guest
 
Posts: n/a
Default 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


  #8  
Old October 20th, 2006, 08:05 PM
aeg
Guest
 
Posts: n/a
Default 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

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.