This is a discussion on Setting variables from GET request within the PHP Language forums, part of the PHP Programming Forums category; PHP Newb here... How do I configure php to take a url like this mydomain.com/index.php?v1=value1&...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Sean Berry wrote:
> PHP Newb here... > > How do I configure php to take a url like this > mydomain.com/index.php?v1=value1&v2=value2&v3=value3 > > and automagically create varialbe $v1 throught $v3 and assign > the corresponding values? extract($_GET) will do that. Personally I like to be able to see at a glance where my variables come from, so I would use $_GET['v1'] through $_GET['v3']. JP -- Sorry, <devnull@cauce.org> is a spam trap. Real e-mail address unavailable. 5000+ spams per month. |
|
|||
|
> extract($_GET) will do that. Personally I like to be able to see at a
> glance where my variables come from, so I would use $_GET['v1'] through > $_GET['v3']. Me too. Actually I habitually do something like: $v1 = sanitise( $_GET['v1'] ); unset $_GET['v1']; so I use the conveniently named variable, but only after ensuring it is safe to do so. Taking shortcuts with user supplied values isn't a good idea, IMHO. -- The email address used to post is a spam pit. Contact me at http://www.derekfountain.org : <a href="http://www.derekfountain.org/">Derek Fountain</a> |
|
|||
|
I should have probably included a better explanation in
the original post... so here goes. I have several php scripts written by a third party that are being hosted on my servers. The scripts work fine on the servers that they were written on, but seem to have a recurring problem on my servers. Both servers have PHP v. 4.3.6. The problem that keeps coming up is that the author of the scripts uses a lot of if (isset($varname)) { do something; } But, $varname is never set explicitly like this: $varname = $_GET('varname'); When I add the types of assignments above, pieces start to work. But there are nearly 100 php files, and lots of vars in each. For example - the variable $cid is never set explicitly via $id = $_GET('cid'); yet mysql querries using $cid as a variable work fine on his server - as long as the url contains ...&cid=(somevalue)... The only reason I could come up with as to why the scripts act differently on his server vs. mine is that he must have compiled php to do the variable parsing and assignment from a GET request automatically. Is there any other explanation? Thanks for any and all help. |
|
|||
|
I noticed that Message-ID: <oLKQd.32731$6u.17692@fed1read02> from Sean
Berry contained the following: >The only reason I could come up with as to why the scripts >act differently on his server vs. mine is that he must have compiled >php to do the variable parsing and assignment from a GET request >automatically. Is there any other explanation? The reason is that he has register globals on and you don't. As your setup is now regarded as being the better option, you are right and he is wrong. Your script author should know this and should be prepared to fix the scripts. But beware of quick and dirty fixes like using extract() <says he, having to do exactly that this afternoon to get a script working again quickly. Heh...> -- Geoff Berrow (put thecat out to email) It's only Usenet, no one dies. My opinions, not the committee's, mine. Simple RFDs http://www.ckdog.co.uk/rfdmaker/ |
|
|||
|
"Sean Berry" <sean@buildingonline.com> wrote in
news:oLKQd.32731$6u.17692@fed1read02: > I should have probably included a better explanation in > the original post... Actually, you shouldn't have posted the same question more than once ;-) I answered your posting in alt.php What is the accepted way to share a message across multiple newsgroups? http://smjg.port5.com/faqs/usenet/xpost.html -- Dave Patton Canadian Coordinator, Degree Confluence Project http://www.confluence.org/ My website: http://members.shaw.ca/davepatton/ |
|
|||
|
"Dave Patton" <spam@trap.invalid> wrote in message news:Xns95FF69DD64BEBmrzaphoddirectcaold@24.71.223 .159... > "Sean Berry" <sean@buildingonline.com> wrote in > news:oLKQd.32731$6u.17692@fed1read02: > >> I should have probably included a better explanation in >> the original post... > > Actually, you shouldn't have posted the same question > more than once ;-) > > I answered your posting in alt.php > > What is the accepted way to share a message across multiple newsgroups? > http://smjg.port5.com/faqs/usenet/xpost.html > > -- > Dave Patton > Canadian Coordinator, Degree Confluence Project > http://www.confluence.org/ > My website: http://members.shaw.ca/davepatton/ Dave, Sorry about crossposting - this is actually my first time doing so. I was worried that nobody was going to read my revised post. Also, thank you for pointing out the link clarifying the proper way to post to multiple groups. |