New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
Web Design and Hosting Creating sites, scripting, and hosting discussions.

Anyone help me figure out why php won't run even though I'm using MAMP


Post Reply New Thread Subscribe

 
Thread Tools
zipsfan21

 
Member Since: Feb 06, 2011
Posts: 2
zipsfan21 is on a distinguished road

zipsfan21 is offline
First off I am new to the web design/programming world and this will probably be akin to someone posting to an automotive forum "How do I put a spare tire on?"

So I'm trying to get PHP up and running on my MBP. I am new to programming like I said, however I'm not bad at getting into dreamweaver and making changes to get things how I want to look and can get files saved from there opened via Safari/Firefox just fine. Now I'm trying to run a very basic php script (going through a php for absolute beginners page to start to learn it) just so I can check to make sure systems are all running. I've installed MAMP and it turns on fine and shows as everything working there. However when I open up the script I saved (PHPtest1.php) all the code appears along with text rather then the clean text. I'm not sure if I'm leaving out any info you might need but any and all help would be appreciated as I've just lost a ton of time to figuring out something that by all accounts should be quick and painless. I do have "websharing" turned on in my preferencs.


Here is the script that I try to open (and consequently appears in the broswer exactly this way) :


<html>
<head></head>
<body>

Agent: So who do you think you are, anyhow?
<br />

<?php
// print output
echo 'Neo: I am Neo, but my people call me The One.';
?>

</body>
</html>
QUOTE Thanks
wheelguy

 
wheelguy's Avatar
 
Member Since: Jun 18, 2006
Location: Minneapolis
Posts: 191
wheelguy will become famous soon enough
Mac Specs: MacBook Pro

wheelguy is offline
You have the text marked out with the // and you only need the print or echo command
<?php print "Neo: I am Neo, but my people call me The One."; ?>

Here is a good place to start PHP Tutorial

If you aren't fired with enthusiasm, you will be fired with enthusiasm. -Vince Lombardi
QUOTE Thanks
mjfleck2000

 
Member Since: Apr 07, 2008
Location: Coeur d' Alene, Idaho
Posts: 17
mjfleck2000 is on a distinguished road
Mac Specs: Macbook Pro, iMac

mjfleck2000 is offline
I had a jolly time getting php working. It wasn't hard, just needed a few defaults in the php.ini file changed... especially the option for "short_tags".

In /etc/php.ini, under Language Options, change

short_open_tag = Off


to

short_open_tag = On

Once I did this, my php files worked.

Also, the first file I would use to verify php is one like this that I made: I make a file called phpinfo.php. In this file I typed:

<?php
phpinfo();
?>


If php is working, you will get a printout of all php's configuration. VERY helpful to diagnose problems.

Hope this helps.

Mike
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,817
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
I am by no means a PHP expert but I believe the issue has something to do with the permissions on the page. Try the following:

1. Open up Terminal (/Applications/Utilities) and type the following:
Code:
chmod 644
2. Now, drag the php file from Finder onto the Terminal window. The line in the terminal should now something like the following:
Code:
chmod 644 /path/to/phpfile/file.php
Press enter. Reload the page.

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks
zipsfan21

 
Member Since: Feb 06, 2011
Posts: 2
zipsfan21 is on a distinguished road

zipsfan21 is offline
Before I try fooling with anything in terminal I just wanted to give everyone an update. I tried saving the .php files to sites in "User" on the HD and voila php scripts run beautifully from there. Not sure if this would pinpoint why when saved to MAMP (Applications> Mamp> phpscript.php) php won't run.
QUOTE Thanks

Post Reply New Thread Subscribe


« Easy iweb publisher help!! | Move from PC to Mac what about Dreamweaver? »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
sending mail through php buratti Web Design and Hosting 0 07-09-2010 09:14 AM
Trying to run a new printer on an old iMac chakers Running Windows (or anything else) on your Mac 3 07-06-2010 11:02 PM
Error trying to run boot camp partition of XP with VMware humdingah Running Windows (or anything else) on your Mac 1 11-10-2008 09:57 PM
Apache, php and mysql on leopard skorpyo Web Design and Hosting 1 01-18-2008 03:38 AM
Scripting a cron job to post data to a url via variable lizardthefish OS X - Development and Darwin 4 02-14-2004 04:33 PM

All times are GMT -4. The time now is 06:43 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?