[PHP] newbie question about scope

2003-11-12 Thread news.comcast.giganews.com
I am an experienced web developer who is just getting into php.  I have had
a php project fall into my lap and wanted a little advice.  Here is the
scoop:

A client moved their site from a server (unknown details) to a hosting
facility (php 4.3.2).  Now none of the scripts work.  I have guessed that
they are coming from an earlier version of apache/php.  Anyway it appears
that whoever created the site in the first place did not believe in scoping
variables.  Now any variable that is not properly scoped will not be read by
the server.  I know I can simply scope all of the variables, but I was
hoping there may be an easier way.  Also, how bad is the _REQUEST scope I
read that it could not be trusted, however the previous developer created
the app in such a way that several places a variable could be _GET or _POST.
I apologize for the rambling and possible incoherency of this message, I am
a bit tired.

Matthew

PS. How do you scope queries?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] newbie question about scope

2003-11-12 Thread Derek Ford
news.comcast.giganews.com wrote:

I am an experienced web developer who is just getting into php.  I have had
a php project fall into my lap and wanted a little advice.  Here is the
scoop:
   A client moved their site from a server (unknown details) to a hosting
facility (php 4.3.2).  Now none of the scripts work.  I have guessed that
they are coming from an earlier version of apache/php.  Anyway it appears
that whoever created the site in the first place did not believe in scoping
variables.  Now any variable that is not properly scoped will not be read by
the server.  I know I can simply scope all of the variables, but I was
hoping there may be an easier way.  Also, how bad is the _REQUEST scope I
read that it could not be trusted, however the previous developer created
the app in such a way that several places a variable could be _GET or _POST.
I apologize for the rambling and possible incoherency of this message, I am
a bit tired.
Matthew

PS. How do you scope queries?

 

You're thinking about this in the wrong way, it seems. The server 
probably has register_globals Off, where previously he was programming 
with it being On. or vise-versa. They should be Off, and should be left 
off, but programming with them off needs some adjusting. Variables such 
as post and get data are now 'superglobals', and must use the 
appropriate arrays; $_GET[], and $_POST[]. There are things like 
extract(), but using them is not advised. as per your question about 
scope queries, be more concrete :)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] newbie question about scope

2003-11-12 Thread Jay Blanchard
[snip]
A client moved their site from a server (unknown details) to a
hosting
facility (php 4.3.2).  Now none of the scripts work.  I have guessed
that
they are coming from an earlier version of apache/php.
[/snip]

It is likely then that register_globals is set to OFF in the php.ini. In
earlier versions this directive was set to ON. It was a security issue
that was more about bad coding than a PHP vulnerability. If you passed a
form field with the name of userName it could be accessed by PHP in the
$userName variable, with RG off you would have to access it via
$_GET['userName'] or $_POST['userName'] dependent upon the processing
method of the form.

[snip]
Also, how bad is the _REQUEST scope I read that it could not be
trusted
[/snip]

Again, bad coding would present a danger here.

[snip]
PS. How do you scope queries?
[/snip]

I am not sure what you are asking here. Do you mean making a query
public or private?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] newbie question about scope

2003-11-12 Thread news.comcast.giganews.com

Derek Ford [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 news.comcast.giganews.com wrote:

 I am an experienced web developer who is just getting into php.  I have
had
 a php project fall into my lap and wanted a little advice.  Here is the
 scoop:
 
 A client moved their site from a server (unknown details) to a
hosting
 facility (php 4.3.2).  Now none of the scripts work.  I have guessed that
 they are coming from an earlier version of apache/php.  Anyway it appears
 that whoever created the site in the first place did not believe in
scoping
 variables.  Now any variable that is not properly scoped will not be read
by
 the server.  I know I can simply scope all of the variables, but I was
 hoping there may be an easier way.  Also, how bad is the _REQUEST scope I
 read that it could not be trusted, however the previous developer
created
 the app in such a way that several places a variable could be _GET or
_POST.
 I apologize for the rambling and possible incoherency of this message, I
am
 a bit tired.
 
 Matthew
 
 PS. How do you scope queries?
 
 
 
 You're thinking about this in the wrong way, it seems. The server
 probably has register_globals Off, where previously he was programming
 with it being On. or vise-versa. They should be Off, and should be left
 off, but programming with them off needs some adjusting. Variables such
 as post and get data are now 'superglobals', and must use the
 appropriate arrays; $_GET[], and $_POST[]. There are things like
 extract(), but using them is not advised. as per your question about
 scope queries, be more concrete :)

I agree that is the way it should be, but my client is looking for a quick
fix, not a good one.  In the end it is fortunate for my client that the
quick fix is not a viable one.  I agree that all variables should be scoped,
it is the right way to do things.  I think I have my query question figured
out.

Thanks

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] newbie question about scope

2003-11-12 Thread Jay Blanchard
[snip]
Unless I'm misunderstanding something, PHP does not implement
scoping (at least in the sense that many other programming languages
do) prior to PHP5.  
[/snip]

Actually it does implement scoping, see
http://us2.php.net/language.variables.scope

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php