SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: help my codes

  1. #1
    SitePoint Evangelist
    Join Date
    Apr 2002
    Posts
    523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help my codes

    Hi how are you doing?

    My coding is something wrong. Before it was ok and running. But it is not working now. After entring datas, "Thank you for filling out my form" should come. However, it doesn't show up.

    My phpeditor says "You don't have permission to access "

    Please help me

    Here is my code. My php is 4.2

    <html>

    <body>


    <?php
    $con = mysql_connect("localhost","itohideo","1234");


    if(!$con)
    {
    print("Fail DB Connection<br>\n");
    exit;
    }

    if(!mysql_select_db("itohideo"))
    {
    print("Fail DB Selection<br>\n");
    exit;
    }
    if (isset($_POST["submit"]))
    {
    $number = $_POST["number"];
    $name = $_POST["name"];
    $country = $_POST["country"];

    $query_insert = "insert into takao (number, name, country) values ('$number', '$name', '$country')";
    $query_result_insert = mysql_query($query_insert, $con) or die (mysql_error($con));

    echo "Thank you for filling out my form";

    mysql_close($con);

    }
    ?>

    <form method="post" action="<?php print $HTTP_SERVER_VARS["PHP_SELF"]; ?>">
    <P>please fill out this form and it goes to my database</P>
    Number<input name="number" type="text"><br>
    Name<input name="name" type="text"><br>
    You country<input name="country" type="text"><br>

    <input type="submit" name="submit">
    <input type="reset" name="reset">

    </form>
    </body>
    </html>

  2. #2
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't see anything wrong so make sure your connection variables are right. itohedeo is both username and database name??

    Also, minor issue, change this:
    PHP Code:
    $HTTP_SERVER_VARS["PHP_SELF"]; 
    to
    PHP Code:
    $_SERVER['PHP_SELF']; 

    Sketch
    Aaron Brazell
    Technosailor



  3. #3
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: help my codes

    Originally posted by itohideo
    Hi how are you doing?
    Good thanks

    PHP Code:
    $query_result_insert mysql_query($query_insert$con) or die (mysql_error($con)); 
    I assume this is the offending line. WHat is the exact error?

    BTW you do realise you do your connections in a really weird order.. basically you connect to the database AND then check to see if your form has been submitted. Though it will probably make little difference I would always check to see if the form had been submitted and then if necessary open a connection to the database.

    FINALLY PLEASE USE SYNTAX HIGHLIGHTING!
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  4. #4
    SitePoint Evangelist
    Join Date
    Apr 2002
    Posts
    523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    still not working yet

    I tried both way but it is not working

    What should I do?

  5. #5
    SitePoint Evangelist
    Join Date
    Apr 2002
    Posts
    523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    My phpeditor says?

    They say"You don't have permission to access "

    That's it

  6. #6
    SitePoint Evangelist
    Join Date
    Apr 2002
    Posts
    523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Now it works

    Thank you guys

    Now it works

    I saved as php4 so that it didn't work

    Then I save as php

    it works

    What is the diffrent?

    Please explain to me

    Thank you


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
  •