Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8883607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:51:17+00:00 2026-06-14T20:51:17+00:00

I try to insert multiple rows with different values but I don’t know why

  • 0

I try to insert multiple rows with different values but I don’t know why doesn’t work

$id_poliza = $this->dbConnect->lastInsertId(); //With this, I save last insert id from last executed sql statement.

if($this->dataNewPoliza['d724'] == 'on')
    $disp1 = 1;
else
    $disp1 = 0;
if($this->dataNewPoliza['d58'] == 'on')
    $disp2 = 1;
else
    $disp2 = 0;
if(($this->dataNewPoliza['especial']) == '')
    $disp3 = 0;
else
    $disp3 = $this->dataNewPoliza['especial'];

if(($this->dataNewPoliza['ticket']) == '')
    $disp4 = 0;
else
    $disp4 = $this->dataNewPoliza['ticket'];

$sqlDispPol = "INSERT INTO disponibilidad_poliza (Id_Poliza, Id_Disponibilidad, Valor)
    VALUES (:idP,:idD1,:val1), 
           (:idP,:idD2,:val2), 
           (:idP,:idD3,:val3),
           (:idP,:idD4,:val4)";
$resultDisp = $this->dbConnect->prepare($sqlDispPol) or die ($sqlDispPol);

$resultDisp->bindParam(':idP',$id_poliza,PDO::PARAM_INT);

$resultDisp->bindParam(':idD1',1,PDO::PARAM_INT);
$resultDisp->bindParam(':val1',$disp1,PDO::PARAM_STR);

$resultDisp->bindParam(':idD2',2,PDO::PARAM_INT);
$resultDisp->bindParam(':val2',$disp2,PDO::PARAM_STR);

$resultDisp->bindParam(':idD3',3,PDO::PARAM_INT);
$resultDisp->bindParam(':val3',$disp3,PDO::PARAM_STR);

$resultDisp->bindParam(':idD4',4,PDO::PARAM_INT);
$resultDisp->bindParam(':val4',$disp4,PDO::PARAM_STR);

if($resultDisp->execute()) {
         //more code
    }

I want save from this form:

Table disponibilidad_poliza

Id_Poliza     Id_Disponibilidad   Valor
________________________________________
   1                1               1
   1                2               0
   1                3               especial10
   1                4               7

Note: $disp1 and $disp2 are checkboxes, $disp3 and $disp4 are inputs text

Maybe this way is incorrect and I appreceate If you put another way to do this please.
Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:51:18+00:00Added an answer on June 14, 2026 at 8:51 pm

    Use bindValue() instead of bindParam(). It takes the same arguments but will work with raw integers and other scalars. The method bindParam() needs explicitly a parameter to be bound to and from what i see you doing you don’t need to use it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I try this statement: INSERT INTO TerminalEventChild (id,stringValue) VALUES (64,'version123|'); MySQL fail with
I know that I can insert multiple rows using a single statement, if I
In MySQL you can insert multiple rows like this: INSERT INTO 'tablename' ('column1', 'column2')
I am trying to insert huge multiple rows in a single transaction. But the
I'm working with page template in WordPress (don't matter). I'll try insert a picture
I am trying to insert today's date and try increment the date recursively. but
I read this question , which highlights a solution to conditionally insert values into
I am trying to insert multiple rows in a listitems to a database using
I am trying to insert multiple rows in a MySQL table from PHP arrays.
I'm trying to insert multiple rows using transaction-bind through PHP PDO. Below is my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.