SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Member
    Join Date
    Feb 2014
    Location
    Maricopa, AZ
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,941
    Mentioned
    215 Post(s)
    Tagged
    12 Thread(s)
    Hi,

    what is the contents of today.php?

  3. #3
    SitePoint Member
    Join Date
    Feb 2014
    Location
    Maricopa, AZ
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <!DOCTYPE html>
    <html lang= “en”>
    <head>
    <meta charset=”utf -8”>
    <title>Today&rsquo;s Date</Title>
    </head>
    <body>
    <p>Today&rsquo;s date (according to this web server) is

    <?php

    echo date(‘l F jS Y.’);

    ?>
    </p>
    </body>
    </html>

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,203
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Try straight quotes in your code (and make sure you are using a code editor rather than something like Word):

    Code:
    echo date('l F jS Y.');
    You had curly quotes in there, which cause problems.

  5. #5
    SitePoint Member
    Join Date
    Feb 2014
    Location
    Maricopa, AZ
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The only single quotes I see on my keyboard are below the double quotes. Not sure I have another option.

  6. #6
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,203
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by dsmithqntm View Post
    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).

  7. #7
    SitePoint Member
    Join Date
    Feb 2014
    Location
    Maricopa, AZ
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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...

  8. #8
    Community Advisor silver trophybronze trophy
    dresden_phoenix's Avatar
    Join Date
    Jun 2008
    Location
    Madison, WI
    Posts
    2,804
    Mentioned
    34 Post(s)
    Tagged
    2 Thread(s)
    Code:
    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

  9. #9
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,941
    Mentioned
    215 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by dsmithqntm View Post
    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 problem is the single quotes.

    You have:
    Code:
    echo date(‘l F jS Y.’);
    You need:
    Code:
    echo date('l F jS Y.');
    Quote Originally Posted by dsmithqntm View Post
    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.
    The above error was that you had the wrong sort of quotes.
    Let's get that sorted out before moving on

  10. #10
    SitePoint Member
    Join Date
    Feb 2014
    Location
    Maricopa, AZ
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I downloaded TextWrangler, copied the code into that editor and got the same error message.

  11. #11
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,941
    Mentioned
    215 Post(s)
    Tagged
    12 Thread(s)
    Did you ensure that the quotes were ok?

    Here's the entire code to copy/paste:

    Code:
    <!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>

  12. #12
    SitePoint Member
    Join Date
    Feb 2014
    Location
    Maricopa, AZ
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I'll be damned. Copied this code into TextWrangler, ran it as today4.php. It worked.
    Thanks very much. Regards, David


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •