SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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&rsquo;s Date</title> <br>
    <meta http-equiv="content-type" <br>
    content="text/html; charset=utf-8"/> <br>
    </head> <br>
    <body> <br>
    <p>Today&rsquo;s date (according to this web server) is <br>
    <?php <br>
    <br>
    echo date('l, F dS Y.'); <br>
    <br>
    ?> <br>
    </p> <br>
    </body> <br>
    </html>

    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.

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,810
    Mentioned
    141 Post(s)
    Tagged
    0 Thread(s)
    You have syntax errors in your PHP section (unless those BR tags were added by you later).
    PHP Code:
    <!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">   
        <head>
            <title>Today&rsquo;s Date</title>   
            <meta http-equiv="content-type" content="text/html; charset=utf-8"/>   
        </head>   
        <body>   
            <p>
                Today&rsquo;s date (according to this web server) is   
                <?php     
                    
    echo date('l, F dS Y.');   
                
    ?>   
            </p>   
        </body>   
    </html>
    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.
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  3. #3
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,598
    Mentioned
    411 Post(s)
    Tagged
    6 Thread(s)
    Hi iHamza. Welcome to the forums.

    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.

  4. #4
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,747
    Mentioned
    64 Post(s)
    Tagged
    0 Thread(s)
    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.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  5. #5
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cpradio View Post
    You have syntax errors in your PHP section (unless those BR tags were added by you later).
    PHP Code:
    <!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">   
        <head>
            <title>Today&rsquo;s Date</title>   
            <meta http-equiv="content-type" content="text/html; charset=utf-8"/>   
        </head>   
        <body>   
            <p>
                Today&rsquo;s date (according to this web server) is   
                <?php     
                    
    echo date('l, F dS Y.');   
                
    ?>   
            </p>   
        </body>   
    </html>
    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.


    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. ^_^

    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.

  6. #6
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ralph.m View Post
    Hi iHamza. Welcome to the forums.

    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.
    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. ^_^

  7. #7
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StarLion View Post
    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 replying , StarLion.

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

  8. #8
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cpradio View Post
    You have syntax errors in your PHP section (unless those BR tags were added by you later).
    PHP Code:
    <!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">   
        <head>
            <title>Today’s Date</title>   
            <meta http-equiv="content-type" content="text/html; charset=utf-8"/>   
        </head>   
        <body>   
            <p>
                Today’s date (according to this web server) is   
                <?php     
                    
    echo date('l, F dS Y.');   
                
    ?>   
            </p>   
        </body>   
    </html>
    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.

    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


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
  •