Call to undefined method PDO::execute()

user3531649

i'm trying to code a page login but i was stopper at this error

pliz tell me the wrong thing here

<?php
@session_start();
include("../../connexion/connexion.php");
class login_class {
        public $user;
        public $password;
        public $connexion;
    public function check_login() {
        try {
            $cn = new class_connect();
            $this->connexion = $cn->connect(null);
            $result = $this->connexion->execute("select * from user where username='$this->user' and password='$this->password'");

                        $data = $result->fetchAll(PDO::FETCH_OBJ);


            if (!empty($data[0]->id_user)) {
                return true;
            }else {
                return false;
            }
        }catch(PDOException $ex) {  
            echo $ex->getMessage();
        }
    }
    public function __construct($user) {
        if($user){
            $this->user = $user["username"];
            $this->password = $user["password"];
        }
    }

}
?>
Marc B

->execute() is for prepared statements. e.g.

$stmt = $dbh->prepare('some query here');
$stmt->execute();

You're trying to execute a query directly on the main DB object. For PDO, that means

 $dbh->exec('query goes here');

You really should look into prepared statements. You're vulnerable to SQL injection attacks as is, and since you're using PDO to begin with, it's basically unforgivable to NOT be writing safe queries.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Call to undefined method PDO execute

From Dev

"Undefined method PDO::execute()" despite using prepare

From Dev

Fatal error: Call to undefined method PDO::sqlsrv_prepare()

From Dev

Fatal error: Call to undefined method PDO::select() in line 9

From Dev

PDO fetchAll method undefined

From Dev

CodeIgniter PDO - Call to undefined method CI_DB_pdo_mysql_driver::num_rows()

From Dev

call to undefined function execute()

From Dev

call to undefined function execute()

From Dev

Fatal error: Call to undefined method Varien_Db_Adapter_Pdo_Mysql::createTemporaryTable() in Magento

From Dev

Fatal error: Call to undefined method CI_DB_pdo_driver::where() in

From Dev

Can not call method of undefined

From Dev

Call to undefined method error

From Dev

The method execute() is undefined for the type InvoiceTemplateGet

From Dev

PDO bind_param is undefined method

From Dev

PHP PDO Undefined method DatabaseHandler::prepare()

From Dev

Call to undefined method Slice in Doctrine

From Dev

Error: Call to a possibly undefined method

From Dev

Laravel 5 - Call to undefined method

From Dev

Laravel - Call to undefined method in repository

From Dev

Call to undefined method DOMDocument::getElementsByClassName()

From Dev

Rails 4.0 undefined method `call'

From Dev

TypeError: Cannot call method 'then' of undefined

From Dev

Cannot call method 'use' of undefined

From Dev

Call to undefined method (laravel 5.2)

From Dev

Call to undefined method Closure::query()

From Dev

Call to undefined method Imagick::writeImageFile()

From Dev

BackboneJS - Cannot call method 'on' of undefined

From Dev

Call to undefined method SimpleXMLElement::getAttribute()

From Dev

Javascript: Cannot call method of undefined

Related Related

  1. 1

    Call to undefined method PDO execute

  2. 2

    "Undefined method PDO::execute()" despite using prepare

  3. 3

    Fatal error: Call to undefined method PDO::sqlsrv_prepare()

  4. 4

    Fatal error: Call to undefined method PDO::select() in line 9

  5. 5

    PDO fetchAll method undefined

  6. 6

    CodeIgniter PDO - Call to undefined method CI_DB_pdo_mysql_driver::num_rows()

  7. 7

    call to undefined function execute()

  8. 8

    call to undefined function execute()

  9. 9

    Fatal error: Call to undefined method Varien_Db_Adapter_Pdo_Mysql::createTemporaryTable() in Magento

  10. 10

    Fatal error: Call to undefined method CI_DB_pdo_driver::where() in

  11. 11

    Can not call method of undefined

  12. 12

    Call to undefined method error

  13. 13

    The method execute() is undefined for the type InvoiceTemplateGet

  14. 14

    PDO bind_param is undefined method

  15. 15

    PHP PDO Undefined method DatabaseHandler::prepare()

  16. 16

    Call to undefined method Slice in Doctrine

  17. 17

    Error: Call to a possibly undefined method

  18. 18

    Laravel 5 - Call to undefined method

  19. 19

    Laravel - Call to undefined method in repository

  20. 20

    Call to undefined method DOMDocument::getElementsByClassName()

  21. 21

    Rails 4.0 undefined method `call'

  22. 22

    TypeError: Cannot call method 'then' of undefined

  23. 23

    Cannot call method 'use' of undefined

  24. 24

    Call to undefined method (laravel 5.2)

  25. 25

    Call to undefined method Closure::query()

  26. 26

    Call to undefined method Imagick::writeImageFile()

  27. 27

    BackboneJS - Cannot call method 'on' of undefined

  28. 28

    Call to undefined method SimpleXMLElement::getAttribute()

  29. 29

    Javascript: Cannot call method of undefined

HotTag

Archive