Jump to content

pdo runs twice when everything else is commented out


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?

  On 12/29/2014 at 10:23 PM, NotionCommotion said:

Also, what is $id equal to?

ID as always is normally user id.

 

 

  On 12/29/2014 at 10:44 PM, Jacques1 said:
printf('<br>Inserted rows: %d<br>', $q_news->rowCount());

it returns: Inserted rows: 1

  On 12/29/2014 at 10:23 PM, NotionCommotion said:

 

 

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)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.