Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > PHP on OSX

PHP on OSX
Thread Tools
slimshady023
Forum Regular
Join Date: Apr 2000
Location: California
Status: Offline
Reply With Quote
Nov 15, 2004, 02:02 PM
 
Hi all,

I just installed PHP on OSX, and am having issues getting PHP to process my url actions. For instance, the url:

http://localhost/~dude/test.php?action=uno
It should display a message saying "Page One", based on the code below. However, it always defaults to "No Action."

When I put the same code on my server, it processes my actions without problem. How can I configure my Mac to serve this correctly?

Thanks!
- Slim

The code from test.php

<?
if ($action == "uno") {
echo("Page One");
}

else if ($action == "dos") {
echo("Page Two");
}

else {
echo("No Action.");
}

?>
     
Chris O'Brien
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status: Offline
Reply With Quote
Nov 15, 2004, 02:18 PM
 
the variable $action doesn't exist because global variables are turned off by default. Try:
[php]
<?
$action = $_GET['action'];
if ($action == "uno") {
echo("Page One");
}

else if ($action == "dos") {
echo("Page Two");
}

else {
echo("No Action.");
}

?>

[/php]
Just who are Britain? What do they? Who is them? And why?

Formerly Black Book
     
slimshady023  (op)
Forum Regular
Join Date: Apr 2000
Location: California
Status: Offline
Reply With Quote
Nov 15, 2004, 03:52 PM
 
Thank you so much, Black book...

I had no idea about the global variables being turned off for OSX, but have read about that in regards to security concerns. Anyway, it worked perfectly!

Cheers from California!
- Slim
     
larkost
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status: Offline
Reply With Quote
Nov 15, 2004, 07:04 PM
 
It is not just MacOS X... that is now the default for PHP.
     
   
 
Forum Links
Forum 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 On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 04:07 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,