Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    May 2008
    Posts
    70
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Help on inserting values into 2 tables at once

    Hi, i need help again x(. I'm trying to put 2 different values into 2 different tables upon registration. The script works fine and redirect out but no sign of record is shown on my database.

    PHP Code:
    if ($Pass == $Pass2) {
        $user = mysql_query("SELECT * FROM user WHERE (username='$bang')");
        if (mysql_num_rows($user) > 0) {
            ?>
    <script type="text/javascript">
    alert("Sorry, Username taken!");
    history.back();
    </script>
            <?php
        
    }
        else {
            
    $user mysql_query(
            
    "INSERT INTO user (username, password, mail) VALUES ('$name','$pass','$email')");
            
    $user mysql_query(
            
    "INSERT INTO winer (uname, clock) VALUES ('$name','ii')"
            
    );
            
    Header("Location:http://redirected.site");
        }
    }
        else {
        
    ?>
    <script type="text/javascript">
    alert("Your Password did not match!");
    history.back();
    </script>
            <?php
    }
    ?>

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,853
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Try to see any errors in your query by
    Code:
    $user = mysql_query("INSERT INTO user (username, password, mail) VALUES ('$name','$pass','$email')") or die(mysql_error());
            $user = mysql_query(
            "INSERT INTO winer (uname, clock) VALUES ('$name','ii')" ) or die(mysql_error());
    Also make sure that error reporting is turned ON.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •