i have a problem with insert, update and delete with php loop.

Discussion in 'PHP' started by annu101web, Aug 4, 2011.

  1. #1
    Hi,
    i have a problem with insert, update and delete with loop.
    As like…
    $limit=10;
    for($i=0;$i<$limit;$i++)
    {
    $insertData[$s] = array(
    '`userid`' = $user_id[$i],
    ‘`templ_id`’=>$templ_id[$i],
    ‘`form_label`’=>$form_label[$i],
    ‘`form_options`’=>$form_options[$i],
    ‘`form_type`’=> $form_type[$i],
    ‘`field_order`’=> $field_order[$i],
    ‘`freq`’=>$freq[$i]
    );
    $this->insert($this->pRfx() .’cus_contact_form’,$insertData);
    }

    My problem is every time i m able to insert only one row. and getting error that “Warning: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of elements in type definition string doesn’t match number of bind variables in MysqlDb.php on line 240″.
    Please help me to fix.
     
    Last edited: Aug 4, 2011
    annu101web, Aug 4, 2011 IP
  2. Thorlax402

    Thorlax402 Member

    Messages:
    194
    Likes Received:
    2
    Best Answers:
    5
    Trophy Points:
    40
    #2
    Could you provide the whole class you are using? It would be very helpful to see what $this->insert does.
     
    Thorlax402, Aug 4, 2011 IP
  3. annu101web

    annu101web Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Please find attached file.
     

    Attached Files:

    annu101web, Aug 4, 2011 IP
  4. bogi

    bogi Well-Known Member

    Messages:
    482
    Likes Received:
    16
    Best Answers:
    2
    Trophy Points:
    140
    #4
    '`userid`' = $user_id[$i],
    PHP:
    should be

    '`userid`' => $user_id[$i],
    PHP:
     
    bogi, Aug 4, 2011 IP
  5. annu101web

    annu101web Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yes Bogi, that is my mistake while i was typing here. But still not working. you can check my attached file.
     
    annu101web, Aug 4, 2011 IP
  6. exodus

    exodus Well-Known Member

    Messages:
    1,900
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    165
    #6
    does the mysql insert class handle an array being passed to it?
     
    exodus, Aug 4, 2011 IP
  7. annu101web

    annu101web Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hi, Find MysqlDb class here.
     

    Attached Files:

    annu101web, Aug 4, 2011 IP
  8. annu101web

    annu101web Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    is anyone there to help me?

    Please.
     
    annu101web, Aug 5, 2011 IP
  9. Thorlax402

    Thorlax402 Member

    Messages:
    194
    Likes Received:
    2
    Best Answers:
    5
    Trophy Points:
    40
    #9
    On line #239 of MysqlDB.php after the close brace, put a print_r($args); and tell me what the page outputs.
     
    Thorlax402, Aug 5, 2011 IP
  10. exodus

    exodus Well-Known Member

    Messages:
    1,900
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    165
    #10
    i would try to help, but it is way to advanced for me to understand. It is telling you that there is a problem in mysqldb.php on line 240. That line is this.. call_user_func_array(array($stmt, 'bind_param'), $args); - from that then it tells you that the vars gave to the call does not match the amount it expected in $stmt var so something is wrong with the $args and the way it is phrased or the stuff you passed to it. The call_user is a valid call, but have to figure why they are miss matched and without really being able to do the output calls that inspect the vars we can go further to debug the script.
     
    exodus, Aug 5, 2011 IP