I installed MAMP and php is not working

Hi guys,

I installed MAMP and everything is working fine but php has a problem.

I’m trying to run this script with this link( http://localhost:8888/today.php):

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” <br>
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”> <br>
<html xmlns=“http://www.w3.org/1999/xhtml” xml:lang=“en” lang=“en”> <br>
<head> <br>
<title>Today’s Date</title> <br>
<meta http-equiv=“content-type” <br>
content=“text/html; charset=utf-8”/> <br>
</head> <br>
<body> <br>
<p>Today’s date (according to this web server) is <br>
<?php <br>
echo date(‘l, F dS Y.’); <br>
?> <br>
</p> <br>
</body> <br>

Safari shows me an empty white page

Am I doing something wrong or did I miss something?

Please if you can help me I’d be thankful.

You have syntax errors in your PHP section (unless those BR tags were added by you later).

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">   
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">   
		<title>Today&rsquo;s Date</title>   
		<meta http-equiv="content-type" content="text/html; charset=utf-8"/>   
			Today&rsquo;s date (according to this web server) is   
				echo date('l, F dS Y.');   

Also, did you verify Apache is running? Also, I highly recommend enabling errors to be displayed in your php.ini file (then restart apache), so you can see what errors are being sent back.

Hi iHamza. Welcome to the forums. :slight_smile:

As cpradio’s code indicates, none of those <br> tags belong in your code. Did you type them yourself, or has you code editor inserted them? If the latter, get a better code editor. :slight_smile:

More to the point, if that is what i assume it to be (You’ve “Save As”'d your Source from the browser window), the problem is that PHP hasnt registered itself with your apache, so the engine doesnt get called to process the PHP tags.

Thanks for your greetings and your reply ,cpradio.

You are right, those BR shouldn’t be in my PHP section and I don’t know where they came from. Maybe from my browser or my text editor. :slight_smile:

Anyway, I verified Apache is running and I will try to enable errors to be displayed and I will tell you the results soon I hope.

Thanks again.

Thanks for greetings, ralph.m.

Actually I don’t know where those BR came from I didn’t type them and I don’t believe my text editor did. :slight_smile:

Thanks for replying , StarLion.

I will try to figure out how to register PHP with Apache if it is not registered.

Many thanks, cpradio.

I copied your code and it worked.

And I enabled errors to be displayed. My error was this:

Parse error: syntax error, unexpected ’ ’ (T_STRING) in /Applications/MAMP/htdocs/h.php on line 11