MYSQL not Executing

Codes here !

Moderators: macek, egami, gesf

JackieChann
New php-forum User
New php-forum User
Posts: 1
Joined: Thu Apr 03, 2014 12:57 am

MYSQL not Executing

Postby JackieChann » Thu Apr 03, 2014 1:03 am

I've spent hours on this and can't understand why this doesn't work.

Code: Select all


    $email = strtolower(filter_input(INPUT_GET, 'email', FILTER_SANITIZE_EMAIL));
    $blog_id = filter_input(INPUT_GET, 'blogId', FILTER_SANITIZE_NUMBER_INT);
    $password = md5(filter_input(INPUT_GET, 'password', FILTER_SANITIZE_SPECIAL_CHARS));

    $id = authenticate($email, $password, $db1);


    if ($id != false) {

        if (!$stmt = $db1->prepare('DELETE FROM blogs WHERE userId=? && blogId=?')) {
            echo "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
        }

       
        // $id, $blog_Id checked here and are correct!       
       
        if (!$stmt->bind_param("ii", $id, $blog_Id)) {
            echo "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
        }


        if (!$stmt->execute()) {
            echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
        }else{
            echo('{"status":"deleted"}');
        }

        $stmt->close();

    }else{
        echo('[{"status":"failed"}]');
    }



{"status":"deleted"} is outputted but the record is not deleted.

If I copy and paste the query into phpmyadmin and run it with the values hard coded it works.

No errors are returned.

The user has privileges to delete and everything else.

Is there anyway I can check it? or see any errors any other way?

Return to “mySQL & php coding”

Who is online

Users browsing this forum: Bing [Bot] and 17 guests