Web Analytics Made Easy -
StatCounter insert query help - CodingForum

Announcement

Collapse
No announcement yet.

insert query help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    plz tell me whats wrong with this.....plz reply soon
    You forgot to tell us the issue that you are facing!
    Digitalocean Cloud Hosting (Referral link - get $10 free credit) Fameco

    Comment


    • #3
      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";
          }
      ?>
      Been a sign maker for 8 years. My business:
      American Made Signs

      Comment


      • #4
        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

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

        Comment


        • #5
          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?
          Digitalocean Cloud Hosting (Referral link - get $10 free credit) Fameco

          Comment


          • #6
            If you want to test again, just truncate the table and start afresh.
            Last edited by ekgrad; Sep 15, 2011, 08:47 AM.

            Comment

            Working...
            X
            😀
            🥰
            🤢
            😎
            😡
            👍
            👎