SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Oct 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Browser only displaying CODE (not Webpages, themselves...)

    First of all, this is my very first post on Sitepoint's forums, and i am thrilled to include myself in such a vast ocean of helpful design resources, so just wanted to get that out of the way..... Ok, onward then; I am reading Build Your Own Database Driven Web Site Using PHP & MySQL by Kevin Yank. So I am past installing all of MySQL, PHP, and Apache, and then uploaded the a php file (called today.php - which is intended to display the current date) to my (apache) server's root directory. All fine, except the issue arises when i then look up the directory via my browser (http://localhost:8080/today.php). The browser simply displays the exact code that I typed, without actually processing the code (html and php) itself, and then outputting the functions.... anyone able to enlighten me to why this is? Any help greatly appreciated, just trying to get on my feet and learning so I can get some things actually done. thanks everyone!

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,868
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Are you using Windows with it set to hide common file extensions? If so then most likely the real filename is today.php.txt and so since it is a .txt file it would just have its content displayed.

    That's about the only reason I can think of for the code appearing exactly as typed. If it was recognising HTML then it wouldn't display all of the content as text.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Member
    Join Date
    Oct 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Right, I'll check that one again.... I typed up the code using Mac Dreamweaver 8 - saving as a .php file ext., so it really shouldn't be the issue at all.... very perplexing, and a really small thing to be tripping me up (so early)! oh well, im sure i will get around it, even if i gotta reinstall everything. I spose i don't NEED it right immediately, however, this is an awesome and valuable developing tool; to be able to TEST a site on a server before it is published, therefore I really want to get this working. Thank You for a response!

  4. #4
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also ensure that you're using <?php and not just <? as php doesn't always have short tags turned on.

    You may also want to consider downloading an all in one preconfigured Apache, PHP and MySQL setup such as XAMPP or the UniformServer. With these you literally extract them from the archive, save the directory to your c: drive and run - it's all setup with no testing , config problems etc. The best thing is you can even put them on a usb drive and run it on any computer. I personally use the uniformserver as xampp takes a lot of diskspace but both are very good.
    I'll do anything to avoid working on my own code

    Are you using: if (isset($_POST['submit'])) ?
    IE has a bug and does not always send the value.

  5. #5
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,314
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    Yes, it's probably something wrong with the PHP/Apache/MySQL setup. As said above, it's easier to install and all-in-one solution, which would be MAMP for you on a Mac. As the book says, it's better to understand how to set up all those programs individually, though.

  6. #6
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,072
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    Locate your Apache config file which should be called httpd.conf and in that file look for a line that reads something like:

    LoadModule php5_module "c:/wamp/bin/php/php5.3.0/php5apache2_2.dll"
    The file location will obviously be different. Once you've found that line, does it have a # at the start of it - if so remove the # from the start of that line, save the file then reboot the server.?

    If that line exists and doesn't have a # at the start of it (is the file location for yourself correct?), have a look for a section in the same file which will look something like:

    <IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig conf/mime.types

    #
    # AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #
    #AddType application/x-gzip .tgz
    #
    # AddEncoding allows you to have certain browsers uncompress
    # information on the fly. Note: Not all browsers support this.
    #
    #AddEncoding x-compress .Z
    #AddEncoding x-gzip .gz .tgz
    #
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php .php3
    AddType application/x-httpd-php .php5

    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    #AddHandler cgi-script .cgi

    # For type maps (negotiated resources):
    #AddHandler type-map var

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    #AddType text/html .shtml
    #AddOutputFilter INCLUDES .shtml
    </IfModule>
    There should be a line in that section.

    AddType application/x-httpd-php .php
    If it's missing then add it with the rest of the AddType application lines, save the file then reboot the server.
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator


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
  •