SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

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

    I try to run this codes but just only sex is not coming. I input name, japanese , sex,but sex doesn't come to my database. I did so many times. But still it is not coming only sex. Please help again.

    Thank you for helping before


    <?php
    $username = "itohideo";
    $password = "1234";
    $host = "localhost";

    $dbcon = mysql_connect($host, $username, $password);
    $database = mysql_select_db("itohideo");

    if (isset($_POST["submit"])) {
    $name = $_POST["name"];
    $japanese = $_POST["japanese"];
    $sex = $_POST["sex"];


    $query_insert = "insert into japan (name, japanese, sex) values ('$name', '$japanese', '$sex')";
    $query_result_insert = mysql_query($query_insert, $dbcon) or die (mysql_error($dbcon));

    $query = "select * from japan";
    $query_result = mysql_query($query, $dbcon);

    $num = mysql_num_rows($query_result);
    print "<table border=\"1\">";
    while ($row = mysql_fetch_array($query_result)) {
    print "<tr>";
    print "<td><b>".$row[0]. "</b> </td><td><b>".$row[1]."</b><br></td>";
    print "<td><b>".$row[2]. "</b> </td><td><b>".$row[3]."</b><br></td>";
    print "<td><b>".$row[4]. "</b> </td><td> <b>".$row[5]."</b><br></td>";
    print "</tr>";
    }
    print "</table>";
    print "there are $num result in the table Japan";
    exit;
    }
    ?>

    <form method="post" action="dc1.php">
    <input name="name" type="text">
    <input name="japanese" type="text">
    <input name="sex" type="text">

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



    </form>

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

    Forget to say

    My php is 4.2 and

    my php says here is wrong

    $sex = $_POST["sex"]; I don't know why

  3. #3
    SitePoint Guru Husain's Avatar
    Join Date
    Sep 2001
    Posts
    620
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you please post the EXACT error message that PHP is giving you. It would help others understand the problem better. Thanks

  4. #4
    SitePoint Wizard johnn's Avatar
    Join Date
    Mar 2001
    Location
    Southern California, USA
    Posts
    1,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is the error message?

    Anyway, you should not placed these codes at top of your script
    PHP Code:
    $username "itohideo"
    $password "1234"
    $host "localhost"

    $dbcon mysql_connect($host$username$password); 
    $database mysql_select_db("itohideo"); 
    You place them where just before you're ready to insert or select


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
  •