New to php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jayman9782
    New Member
    • Mar 2008
    • 10

    New to php

    Ok, this is probably going to sound pretty stupid...so please bear in mind that I'm completely new to php programming. Interested in the buzz about php I've recently downloaded the newest version 5.2.5 as well as MySQL server 5.0 and will be hosting web apps on Apache 2.2. I wrote a very simple program to get a feel for the syntax of php/MySQL programming...
    [php]
    Test.php - user-entered name and username

    <html>
    <form action="Insert. php5" method="post">
    <table width=50% align="Center">
    <tr>
    <td width=50%>Enter your name:</td>
    <td width=50%><inpu t type="text" name="name" /></td>
    </tr>
    <tr>
    <td>Enter your UserName:</td>
    <td><input type="text" name="username" /></td>
    </tr>
    <tr>
    <td></td>
    <td><input type="submit" /></td>
    </tr>
    </table>
    </form>
    </html>

    Insert.php5 - php page that appends users input into MySQL table:
    <?php
    $dbhost = 'localhost:3306 ';
    $dbuser = 'user';
    $dbpass = 'Password';

    $conn = mysql_connect($ dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
    $Currentdb = mysql_select_db ("test", $conn);
    $FName = $_POST['name'];
    $UName = $_POST['username'];
    $sql="INSERT INTO Users (Name, UserName) VALUES ('".$FName."' , '".$UName."' )";

    $result = mysql_query($sq l, $conn) or die('Query failed: ' . mysql_error());
    mysql_close($co nn);
    ?>[/php]This works all fine and dandy when executed through a trial edition of NuSphere but when i simply open my webbrowser to the testpage and enter a name and username it does not execute the php, instead it displays the code as though it's a text file. Is there some sort of packaging I need to include within the php page or framework needed to execute this code for regular deployment? Thanks in advance.
    Jason
    Last edited by ronverdonk; Mar 9 '08, 11:48 PM. Reason: code within tags
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    have you tried changing it from php5 to .php
    Not sure if this is the cause.

    Comment

    • jayman9782
      New Member
      • Mar 2008
      • 10

      #3
      good suggestion but that didn't seem to do the trick.? is there maybe a copilation path or something that i may be missing in the php ini file? the host is seeing the pages, it's just not compiling the php script?

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Silly question, but is apache running?
        (just a suggestion: install something like xampp or phpeasy - they're all bundled with php and mysql(myadmin) )

        Comment

        • jayman9782
          New Member
          • Mar 2008
          • 10

          #5
          apache is running...the script hits the web service when executed/compiled with Nusphere. any other suggestions??.. . i'd rather not uninstall/unconfigure my mysql and php installations but if i can't figure this out i may give phpeasy a try. thanks for the help.

          Comment

          • ronverdonk
            Recognized Expert Specialist
            • Jul 2006
            • 4259

            #6
            New to PHP or not, you still must enclose any code within the proper code tags. See the Posting Guidelines on how to do that.

            moderator

            Comment

            • Markus
              Recognized Expert Expert
              • Jun 2007
              • 6092

              #7
              Unfortunately, no, i don't have anymore suggestions.
              Try asking in an apache specific forum.

              Comment

              Working...