Jump to content

pdo runs twice when everything else is commented out


Go to solution Solved by Q695,

Recommended Posts

$news='news';
$sql_news = "INSERT INTO  `rise`.`news` (
`user` ,
`message`
)
VALUES (
    :id, :news
);";
$q_news = $conn->prepare($sql_news);
$q_news -> execute(array(':id'=>$id,
                  ':news'=>$news));
print_r($q_news);
echo $q_news->rowCount();

Why does it echo 1 instead of 2 when everything else on the page is turned off for processing, and it's the last thing on the page?

 

Why do 2 inserts happen?

 

 

Your indexes in the array should not have the colon in front of them.

 

 

 

Strange, then, that the examples in the manual have the colons

http://php.net/manual/en/pdostatement.execute.php (examples #1, #2)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.