MAMP: PHP can't catch HTTP variables

K

komo

Guest
right now i have a little projects using PHP and MySQL, using MAMP as a development framework on my iBook.
it worked fine to test php scripts and manipulating MySQL databases. but, as the project went on, i found a small but very annoying glitch on my MAMP. whenever i tried to pass HTTP variables, whether using Get or Post methods, the PHP scripts could never catch them.

at first i thought it's just an error on my scripts, but those same scripts works well when i tested them on my Windows machine (using AppServ), so I thought it must be a problem with some configurations, not with my scripts

is there somehow any configurations needed on MAMP that cause my problem??

thx upfront.
 
Joined
Jun 11, 2003
Messages
4,915
Reaction score
68
Points
48
Location
Mount Vernon, WA
Your Mac's Specs
MacBook Pro 2.6 GHz Core 2 Duo 4GB RAM OS 10.5.2
Are you using these variables?

$_POST, $_GET, $_REQUEST, $_SERVER etc? Sometimes people use the old way of coding using register_globals turned on.. which is a no no :)
 
OP
K

komo

Guest
no, i used $<variable-name> e.g. $myvar
do i really have to use those old ways?? i kinda hate it, not practical at all.. :)
 
Joined
Jan 30, 2005
Messages
1,069
Reaction score
59
Points
48
Location
Fort Worth, Texas
Your Mac's Specs
Mac Pro, 8-Core 2.8Ghz, 10GB RAM, 2x1TB HDDs, iPod U2 Edition
Yeah, Sounds like you don't have register globals turned on... You can turn it on in the php.ini file in the conf directory in MAMP. But like Murlyn said if you plan to put this on a live server it is a major security risk.

If you are concerned about putting the $_POST in each line the best way to handle this is to assign all of your variables at the front of the script or even in a seperate include... e.g. $_POST['var1'] = $var1

Just make sure you include them in the header of each function you write as the will not carry otherwise.
 
OP
K

komo

Guest
wow, thanks a lot, i never thought to put an "alias" for HTTP variables, but for now i think i'll stick with global variables. it's just for another school assignment :)
thanks again...
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top