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.
<!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>
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.
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
<!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>