PHP Script not execute but displayed as regular HTML documents

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jimmy Liew
    New Member
    • Apr 2007
    • 7

    PHP Script not execute but displayed as regular HTML documents

    I have a problem executing my php scripts. The scripts displayed as regular HTML documet and not execute. When I view source, it display the full complete php source code I have in the server. I don't really sure whether the bugs is from IIS or php. So far, I have done all necessary steps in setting up php, and phpinfo() executed with no error found.

    Kindly advice. Thank You.
  • coolsti
    Contributor
    • Mar 2008
    • 310

    #2
    Do you have the php start and stop tags in place? <?php and ?>

    Or it might be a server configuration problem, maybe your php engine isn't running.

    By the way, it is a good idea from a security point of view to move most of your PHP code away from the html document tree, so something like this cannot happen. Given the right permissions on the directory folder, your PHP engine can read a file in from another location using "include" or "require" commands which the html server does not have access to. Just put code stubs in your document tree which "include" or "require" the actual script code from another location.

    Comment

    • Jimmy Liew
      New Member
      • Apr 2007
      • 7

      #3
      Originally posted by coolsti
      Do you have the php start and stop tags in place? <?php and ?>

      Or it might be a server configuration problem, maybe your php engine isn't running.

      By the way, it is a good idea from a security point of view to move most of your PHP code away from the html document tree, so something like this cannot happen. Given the right permissions on the directory folder, your PHP engine can read a file in from another location using "include" or "require" commands which the html server does not have access to. Just put code stubs in your document tree which "include" or "require" the actual script code from another location.
      Thanks for your help on this.

      Yes, I have the php start and stop tags in place. The full source codes work fine on another web server. Is that anything I need to configure on IIS, since the IIS has some difficulty to compile the php scripts?

      I have no problem to load the phpinfo(), does it mean that my php is working fine?

      Comment

      • coolsti
        Contributor
        • Mar 2008
        • 310

        #4
        I cannot help with IIS, I am using Linux, so I hope another forum reader can give you some advice here.

        Comment

        • Atli
          Recognized Expert Expert
          • Nov 2006
          • 5062

          #5
          Hi.

          Do you use the <?php ?> tags, or the shorter <? ?> version?
          If you use the short-tag version, try the former.

          You say phpinfo() works? If that is the case, your server does seem to have PHP loaded correctly. Which means this has to be a problem with your code.

          Try putting a phpinfo() file in the same directory as your other code. See if that works.

          Comment

          • kenobewan
            Recognized Expert Specialist
            • Dec 2006
            • 4871

            #6
            Could be as simple as allowing the php we extension in IIS, but I'm not a php user. Try here:
            PHP on IIS

            Comment

            Working...