Novice to ninja newbie with mamp issue in Chap 1

I’m using Mac OS version 10.9.1 and have downloaded MAMP version 5.5.33. Candidly, I gave up after three trials to make MAMP more secure by changing password, after changing it, could not connect to MySQL.

MAMP has two green lights indicating both MySQL and Apache servers are working.

When I try to run today.php from URL I get:

Parse error: syntax error, unexpected ‘F’ (T_STRING) in /Applications/MAMP/htdocs/today.php on line 12

I suspect my setup is not complete, but have researched without success for a few days, hence this thread.

Any help would be welcome.

Hi,

what is the contents of today.php?

<!DOCTYPE html>
<html lang= “en”>
<head>
<meta charset=”utf -8”>
<title>Today’s Date</Title>
</head>
<body>
<p>Today’s date (according to this web server) is

		&lt;?php
		
		echo date(&#8216;l F jS Y.&#8217;);
		
		?&gt;
	&lt;/p&gt;
&lt;/body&gt;

</html>

Try straight quotes in your code (and make sure you are using a code editor rather than something like Word):

echo date('l F jS Y.');

You had curly quotes in there, which cause problems.

The only single quotes I see on my keyboard are below the double quotes. Not sure I have another option.

No, it’s the same keys, and just a matter of what your code editor does with them.

Try cutting and pasting what I posted above and put that straight into the file. What editor are you using? The ones that are not suited for coding turn them straight into “smart quotes”, which are inappropriate for code. You need an editor that won’t convert them (there are plenty of free ones) or you could check the settings of what you are suing and turn off smart quotes (or whatever they are called).

Here’s what I got: Parse error: syntax error, unexpected ‘F’ (T_STRING) in /Applications/MAMP/htdocs/today2.php on line 12

I called the new file today2.php. I use TextEdit as my editor.

The exercise in Chapter 3 of Novice to Ninja asks that we create both a name.html and name.php file. When I run the name file in a URL, I only get the html content, not the php content. I’m thinking this might be related to the above error, namely that php content is not executed for some reason that has escaped me.

Thanks for your help…

I gave up after three trials to make MAMP more secure by changing password, after changing it, could not connect to MySQL.

After you change your info using terminal you have to go back and change some files as well.:
*config.inc.php ( look for the line with '$cfg[‘Servers’][$i][‘password’]

  • index.php (in Applications/MAMP/bin/mamp) ( look for the line with mysql_connect)
  • stopMySQL.sh (in Applications/MAMP/bin/mamp)

remember of course to save.

M$ Words, or any other rich text editor is NOT suitable for coding as it often adds styles and switches characters for in , in an effort to make your documents more typographically correct ( but code is not about typography) . So make sure when using Textedit that you have made the file PLAIN TEXT.

Once you fix that your code should run fine. hope that helps

The problem is the single quotes.

You have:

echo date(&#8216;l F jS Y.&#8217;);

You need:

echo date('l F jS Y.');

The above error was that you had the wrong sort of quotes.
Let’s get that sorted out before moving on :slight_smile:

I downloaded TextWrangler, copied the code into that editor and got the same error message.

Did you ensure that the quotes were ok?

Here’s the entire code to copy/paste:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Today's Date</Title>
  </head>

  <body>
    <p>
      Today's date (according to this web server) is
      <?php echo date('l F jS Y.'); ?>
    </p>
  </body>
</html>

Well, I’ll be damned. Copied this code into TextWrangler, ran it as today4.php. It worked.
Thanks very much. Regards, David