"WAMP Server" problem. PHP code not being executed.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jacotheron
    New Member
    • Jan 2008
    • 44

    "WAMP Server" problem. PHP code not being executed.

    Hi I am new to php. I have started with php as a result of a client. I have downloaded a WAMP (Windows Apaché MySQL PHP). I have a problem: it is proparly installed and everything seems to be working fine except the .php document I try to create. I access the file using the http://localhost/ like the tutorial, I went buying, told me to do but this simple php can't even execute:

    [code=php]<HTML>
    <HEAD>
    <TITLE>My First PHP Page</TITLE>
    </HEAD>
    <BODY>
    <?
    echo "Hello World!";
    ?>
    </BODY>
    </HTML>[/code]

    Can someone please tell me what is wrong with the wamp and how to fix this problem?
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    What happens when you try to execute the .php document?
    Does the PHP code get displayed in the browser?
    Does it get displayed in the source?
    Are there any errors?

    One thing I would advice tho.
    You use <? .. ?> tags in your code. I would recommend using <?php ... ?> tags instead. The former will cause problems on servers using the default PHP settings (PHP5 and above).

    Comment

    • Jacotheron
      New Member
      • Jan 2008
      • 44

      #3
      Originally posted by Atli
      Hi.

      What happens when you try to execute the .php document?
      Does the PHP code get displayed in the browser?
      Does it get displayed in the source?
      Are there any errors?

      One thing I would advice tho.
      You use <? .. ?> tags in your code. I would recommend using <?php ... ?> tags instead. The former will cause problems on server using the default PHP settings (PHP5 and above).
      Thank you for the help, the tags was the problem and now I can start working with PHP

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by Jacotheron
        Thank you for the help, the tags was the problem and now I can start working with PHP
        [code=php]
        <?php
        echo "good luck :)";
        ?>
        [/code]

        Comment

        • Atli
          Recognized Expert Expert
          • Nov 2006
          • 5062

          #5
          Originally posted by Jacotheron
          Thank you for the help, the tags was the problem and now I can start working with PHP
          Glad to hear it :)
          Let us know if we can help you with anything else.

          Comment

          • zabsmarty
            New Member
            • Feb 2007
            • 25

            #6
            WAMP server does n't allow php short tag like <? ?> its allow <?php ?>

            to remove this issue simply go php.ini file look short_open_tag and remove ; if any and make it 'on'

            short_open_tag on

            Comment

            • Atli
              Recognized Expert Expert
              • Nov 2006
              • 5062

              #7
              Originally posted by zabsmarty
              WAMP server does n't allow php short tag like <? ?> its allow <?php ?>

              to remove this issue simply go php.ini file look short_open_tag and remove ; if any and make it 'on'

              short_open_tag on
              An easier solution is to just use the <?php ?> tags ;)
              They will always work without having to mess with the php.ini config.
              Not to mention that on some hosts you don't even have the option to edit the config.

              Comment

              • marnus
                New Member
                • May 2009
                • 2

                #8
                php code still in browser after setting short_open_tag = off

                Hi there
                I'm new to PHP but know some java and C++, I am trying to install my website (www.eventsnamibia.com) on my PC (localhost). I'm using WAMP 2.0h and PHP 5.2.9-2. I have set the short_open_tag to off, but still see PHP code on webpage as oppose to the actual web content. Does anyone have an idea what I should change. Any help is greatly appreciated. Running Windows XP SP3

                Marnus

                Comment

                • Markus
                  Recognized Expert Expert
                  • Jun 2007
                  • 6092

                  #9
                  Originally posted by marnus
                  Hi there
                  I'm new to PHP but know some java and C++, I am trying to install my website (www.eventsnamibia.com) on my PC (localhost). I'm using WAMP 2.0h and PHP 5.2.9-2. I have set the short_open_tag to off, but still see PHP code on webpage as oppose to the actual web content. Does anyone have an idea what I should change. Any help is greatly appreciated. Running Windows XP SP3

                  Marnus
                  If you want to use short tags, you need short_tag_open set to 'On'.

                  Comment

                  • Jacotheron
                    New Member
                    • Jan 2008
                    • 44

                    #10
                    Originally posted by marnus
                    Hi there
                    I'm new to PHP but know some java and C++, I am trying to install my website (www.eventsnamibia.com) on my PC (localhost). I'm using WAMP 2.0h and PHP 5.2.9-2. I have set the short_open_tag to off, but still see PHP code on webpage as oppose to the actual web content. Does anyone have an idea what I should change. Any help is greatly appreciated. Running Windows XP SP3

                    Marnus
                    It is not advisable to run a site from your own PC. Then when you use php, a good practice is to always use the "<?php" tags in stead of the "<?" tags, which are shorter. This way you should not have the problem of php code displayed. Do you use an alias or do you have all your files in the www folder? If you do not use the www folder, and have not set up an alias you would not be able to execute the code through php. If you do use an alias (or the www folder) it should work - the reason it is displayed means that it is not executed. Can you access the default page inserted by the instalation (index.php) through the server?

                    I hope I could help.

                    Comment

                    • Atli
                      Recognized Expert Expert
                      • Nov 2006
                      • 5062

                      #11
                      Just to reiterate this point:

                      There is absolutely NO advantage in using the short tags, aside from the fact that it saves you a few (very very few) keystrokes.

                      Whatever effort you think you are saving yourself by using the short tags will almost definitely be lost (and then some) if you ever have to switch servers, or even if you ever decide to upgrade your PHP installation.

                      It's just not worth the trouble.

                      Comment

                      • marnus
                        New Member
                        • May 2009
                        • 2

                        #12
                        Wamp server problem sorted

                        I have sorted the problem, in the end I had to enable short open tags in the Wamp system tray icon option. Also had to disable notices for error_reporting in PHP config file.

                        The site were designed by someone else, I inherited the short open tags in PHP, will have to look into it to change it. the website is hosted on the internet, i had trouble setting up a localhost installation of the website.

                        Comment

                        • seocanada
                          New Member
                          • Jun 2009
                          • 2

                          #13
                          Originally posted by zabsmarty
                          WAMP server does n't allow php short tag like <? ?> its allow <?php ?>

                          to remove this issue simply go php.ini file look short_open_tag and remove ; if any and make it 'on'

                          short_open_tag on
                          These works to me, thanks a lot.

                          Comment

                          • astrip
                            New Member
                            • Dec 2011
                            • 1

                            #14
                            Hi,

                            I'm having the same problem with WAMP - the PHP code is not being executed. I use only <?php .. ?> tags.

                            Do you have any idea what the problem could be?

                            Thank you

                            Comment

                            Working...