SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast newb40's Avatar
    Join Date
    Jul 2007
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question newbie trouble with PHP

    I'm a newbie posting my first thread...

    Just got PHP to work today using the sitepoint book (Building your own database driven website, pp26-27) example below:

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



    It worked fine this morning, but now when I try opening it the same way...
    through http://localhost.today.php
    it doesn't show the date anymore...and my other textbook examples just spit out the php text (pp50-51)...I don't think the php support is working anymore but I don't know why...I'm not aware of changing anything significant

    I even restarted Apache successfully....

    Anyone have any suggestions?

  2. #2
    SitePoint Addict tina88's Avatar
    Join Date
    Jan 2007
    Location
    UK
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hiya, shouldn't it be http://localhost/today.php

  3. #3
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by tina88 View Post
    Hiya, shouldn't it be http://localhost/today.php
    yup

    welcome to the forums newb40
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  4. #4
    SitePoint Enthusiast newb40's Avatar
    Join Date
    Jul 2007
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Thanks...that was easy!...How about a second one...

    Oops...thanks...that was an easy fix!

    How about a second example straight from the Build your own database driven website book that I'm having trouble with....(pp50-51)

    I saved this as an html file in my root document folder of my Web server software:

    <a href="welcome1.php?name=Kevin">Hi, I'm Kevin!</a>

    And I saved this as a php file in the root folder as well:

    <?php
    $name = $_GET['name'];
    echo "Welcome to our Website, $name!";
    ?>


    And when I open the first file and click on the "Hi I'm Kevin" ....it just spits out the php code of the second file...instead of saying "Welcome to our Website, Kevin!"

    I'm embarassed that I'm not able to accomplish such a simple and basic example, but I am stuck...can someone help me?

  5. #5
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    save it as a .php file and not html....
    that way it will be parsed as a php file
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  6. #6
    SitePoint Enthusiast newb40's Avatar
    Join Date
    Jul 2007
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile Thanks! Worked perfectly!

    Thanks so much! It worked perfectly!

  7. #7
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    keep in there, looks like you're getting the hang of it, pretty soon you'll be doing regular expressions, wooohooo!


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
  •