Jump to content

pdo delete not working


Go to solution Solved by bores_escalovsk,

Recommended Posts

<?php
$db = new PDO('mysql:host=localhost;dbname=wordpress', 'root','');
//---------prepare
$delete3 = $db->prepare("DELETE FROM wp_term_relationships WHERE object_id=:id");
$delete2 = $db->prepare("DELETE FROM wp_posts WHERE ID=:id");
$delete = $db->prepare("DELETE FROM wp_postmeta WHERE post_id=:id");
$select = $db->prepare("SELECT post_id FROM reference WHERE x_id=?");
$delete->bindValue(':id', $id, PDO::PARAM_STR);
$delete2->bindValue(':id', $id, PDO::PARAM_STR);
$delete3->bindValue(':id', $id, PDO::PARAM_STR);
//----------
echo 'conected-----';
{
$delfeed = '';}
$array = explode(',',$delfeed);
foreach($array as $deadman){
$select->execute(array($deadman));
$row = $select->Fetch(PDO::FETCH_ASSOC);
$id = $row['post_id'];
if ($id == null){}
else {
echo "$id"."\n";
$delete->execute();
$delete2->execute();
$delete3->execute();
}
$id++;
}
echo 'done!';
?>

its a simple delete script but it doesnt delete, it does print the right $id's witch means is working till thereĀ but delete goes bananas,double checked table names ,colums... tryied working with question mark place holders insted of bind parameter but nothing

Link to comment
https://forums.phpfreaks.com/topic/290011-pdo-delete-not-working/
Share on other sites

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.