Question

    $deleteID = $_POST['oz'];
    if(!$deleteID){
        echo '2';
        die;    
    } else {
        //It should be working.
    }
    $checkVar = $pdo->prepare("SELECT * FROM `user_posts` WHERE `id`=:delete");
    $checkVar->bindValue(':delete',$deleteID,PDO::PARAM_STR);
    if($checkVar->execute() == false){
        echo '2';
        die;
    }

I'm really pissed off. $deleteID is supplied, nothing is being binded. Why not, please someone help.

Was it helpful?

Solution

  1. make PDO to throw exception on error,
    $pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
    after connect.
  2. Make sure you can see errors occurred, either in logs or on the screen.
  3. Run the very code you posted here, not some other code. As in the other code there can be other errors, irrelevant to your binding problem.

For the Table doesn't exist problem you have to check for mistakes like typos, letter case, wrong server connected, wrong PHP file edited etc. Say, you are running your PHPMyAdmin against localhost while actual script against remote host or something of the kind.

OTHER TIPS

If it says the table does not exist the table does not exist.

You either connect to the wrong server, select the wrong database or you have a case problem.

http://dev.mysql.com/doc/refman/5.5/en/identifier-case-sensitivity.html

[..] Consequently, the case sensitivity of the underlying operating system plays a part in the case sensitivity of database, table, and trigger names. This means such names are not case sensitive in Windows, but are case sensitive in most varieties of Unix.

Make sure you are connecting to the same database and server you are currently looking at

print_r( $pdo );

This is Not an authorization issue.

One more advice. If you are pissed off, take a break, drink a tea, calm down, then read 'Your common sense' excellent answer and watch at your code again :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top