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 6 of 6
  1. #1
    New Coder
    Join Date
    Aug 2011
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    insert query help

    plz tell me whats wrong with this.....plz reply soon

    PHP Code:
    <?php
        $a 
    $_POST['T1'];
        
    $b $_POST['T2'];
        
    $c $_POST['T3'];
        
    $d $_POST['T4'];
        
    $e $_POST['T5'];
        
    $f $_POST['T6'];
        
        
    $con mysql_connect("localhost""root""");
        if(!
    $con)
        {
        echo 
    "error in connection".mysql_error();
        }
        
    mysql_select_db("uc"$con);
        
    $q mysql_query("insert into members values('$a',$b','$c','$d','$e','$f'",$con);
        if(!
    $q)
        {
        echo 
    "error in query".mysql_error();
        }
        if(
    $r mysql_fetch_array($q))
        {
        
    session_start();
        
        
    $_SESSION['sname'] = $a;
        
    header("location:confrmreg.php");    
        }
        else
        {
        echo 
    "invalid id or password try again";
        }
    ?>

  • #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
    plz tell me whats wrong with this.....plz reply soon
    You forgot to tell us the issue that you are facing!
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,447
    Thanks
    71
    Thanked 102 Times in 101 Posts
    You were missing a comma, here you go try this.

    PHP Code:
    <?php
        $a 
    $_POST['T1'];
        
    $b $_POST['T2'];
        
    $c $_POST['T3'];
        
    $d $_POST['T4'];
        
    $e $_POST['T5'];
        
    $f $_POST['T6'];
        
        
    $con mysql_connect("localhost""root""");
        if(!
    $con)
        {
        echo 
    "error in connection".mysql_error();
        }
        
    mysql_select_db("uc"$con);
        
    $q mysql_query("insert into members values('$a','$b','$c','$d','$e','$f'",$con);
        if(!
    $q)
        {
        echo 
    "error in query".mysql_error();
        }
        if(
    $r mysql_fetch_array($q))
        {
        
    session_start();
        
        
    $_SESSION['sname'] = $a;
        
    header("location:confrmreg.php");    
        }
        else
        {
        echo 
    "invalid id or password try again";
        }
    ?>

  • #4
    New Coder
    Join Date
    Aug 2011
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    query err

    its is query error i made changes in query later on it execute successfully but now again its giving error "duplicate key 0 to key 1 "i dont know what is this

    Quote Originally Posted by abduraooft View Post
    You forgot to tell us the issue that you are facing!

  • #5
    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
    You might have a unique/primary key set on a filed and the script may be trying to insert an already used value to the same column. Have you forgot to set an auto_increment on that column?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #6
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you want to test again, just truncate the table and start afresh.
    Last edited by ekgrad; 09-15-2011 at 01:47 PM.


  •  

    Posting Permissions

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