Newbie-Running scripts in Dreamweaver and browser

Discussion in 'PHP' started by yanpearce, Oct 19, 2007.

  1. #1
    I have just started learning PHP and have downloaded and installed XAMPP and all initial tests have gone successfully.

    However I am working through a tutorial using "PHP and MySQL Web Development" and have set up a form which then executes(or should) some PHP code on a results page. If I test the live data in Dreamweaver the code executes correctly but when I use a browser it just regurgitates the PHP code (in firefox) and gives me nothing in Internet explorer.

    Any idea what I am doing wrong?

    Thanks

    yan
     
    yanpearce, Oct 19, 2007 IP
  2. Bronto

    Bronto Peon

    Messages:
    308
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You have set up a form and it is for sure in html code. But how do you arrange the html code in php code?
     
    Bronto, Oct 19, 2007 IP
  3. yanpearce

    yanpearce Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi Bronto

    Yes there is a form which has an action pointing to the php file

    full html is as follows:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><META http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>
    <div>
    <form action="http://processorder.php" method="post" target="_blank" onsubmit="return window.confirm(&quot;You are submitting information to an external page. \nAre you sure?&quot;);">
    <table border="0">
    <tr bgcolor="#cccccc">
    <td width="150">Item</td>
    <td width="15">Quantity</td>
    </tr>
    <tr>
    <td>Tires</td>
    <td align="center"><input type="text" name="tireqty" size="3" maxlength="3"></td>
    </tr>
    <tr>
    <td>Oil</td>
    <td align="center"><input type="text" name="oilqty" size="3" maxlength="3"></td>
    </tr>
    <tr>
    <td>Spark Plugs</td>
    <td align="center"><input type="text" name="sparkqty" size="3" maxlength="3"></td>
    </tr>
    <tr>
    <td>How did you find Bob's?</td>
    <td><select name="find">
    <option value="a">I'm a regular customer</option>
    <option value="b">TV advertising</option>
    <option value="c">Phone directory</option>
    <option value="d">Word of mouth</option>
    </select>
    </td>
    </tr>
    <tr>
    <td colspan="2" align="center"><input type="submit" value="Submit Order"></td>
    </tr>
    </table>
    </form>
    </div>
    </body></html>

    This looks ok but when I submit the form I get the problem that all the browser returns is the php code. It seems wierd that it works within dreamweaver.

    Yan
     
    yanpearce, Oct 20, 2007 IP
  4. rspenc29

    rspenc29 Peon

    Messages:
    256
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    This may be a dumb question but are you sure your php code is wrapped in php tags?

    <?php
    //Your php code
    ?>

    But then it should be if it works in dreamweaver. It sounds like maybe you have a configuration problem on the server.
     
    rspenc29, Oct 20, 2007 IP
  5. yanpearce

    yanpearce Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yes php seems to be properly enclosed in tags. Any pointers on where to start checking sever config. Having said that I have another page interacting with a mySql database and that seems to be ok so I am confused!
     
    yanpearce, Oct 21, 2007 IP
  6. blueparukia

    blueparukia Well-Known Member

    Messages:
    1,564
    Likes Received:
    71
    Best Answers:
    7
    Trophy Points:
    160
    #6
    How are you acessing it via your browser?

    eg. C:\XAMPP\file.php is the wrong way, and should be called via:

    http://localhost/file.php

    BP
     
    blueparukia, Oct 21, 2007 IP
  7. yanpearce

    yanpearce Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    BP

    Many thanks. That's where I was going wrong. It is now running fine.
     
    yanpearce, Oct 21, 2007 IP