Visualizzazione dei risultati da 1 a 3 su 3

Discussione: errore

  1. #1

    errore

    ho il seguente errore:
    Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given

    lo script si compone in due classi
    class usermodel
    {
    private $dbCon = null;

    public function __construct()
    {

    $this->dbCon = new DbCon();
    }

    public function login($email, $password)
    {


    $query = "SELECT * FROM members WHERE email=? LIMIT 1";
    $this->dbCon->preparestatement($query);
    $param_type = 'S';
    $this->dbCon->bindParamsToStatement($param_type,array($email));
    $this->dbCon->execStartement();
    $this->dbCon->storeResult();

    $user_id = 0;
    $username = '';
    $db_password = '';
    $salt = '';

    $this->dbCon->bindResult( &$user_id, &$username, &$db_password, &$salt));
    $this->dbCon->fetchStartement();
    $password = hash('sha512', $password . $salt);

    class DbCon
    {
    private $_dbCon = null;
    private $_statement = NULL;


    public function __construct()
    {
    $this->_dbCon = new mysqli('localhost', 'root', '', 'oop');
    if ($this->_dbCon->errno) {
    echo 'errore di conessione' . $this->_dbCon->error;
    die();
    }
    // inizzio metodi statement
    public function preparestatement($statement){

    $this->_statement = $this->_dbCon->prepare($statement);
    }
    public function bindParamsToStatement( $type, $params ){
    call_user_func_array( array( $this->_statement, 'bind_param' ), array_merge( (array) $type, $params ) );
    }
    public function execStartement(){

    return $this->_statement->execute();
    }

    public function storeResult(){

    $this->_statement->store_result();
    }
    public function bindResult($params){

    $this->_statement->bind_result($params);
    }
    public function fetchStartement(){

    return $this->_dbCon->fetch();
    }

    public function closestartement(){
    $this->_dbCon->close();
    }


    }

    sapete anche come passare in modo dinamico i valori a bind_result()
    mi da il seguente errore Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in C:\Users\giuliano\PhpstormProjects\catalogoMvc\lib rerie\dbCon.php on line 102

    Fatal error: Call to undefined method mysqli::fetch() in C:\Users\giuliano\PhpstormProjects\catalogoMvc\lib rerie\dbCon.php on line 106
    grazzie per l aiuto





  2. #2
    ho sistemato un po di cose pero mi restano questi due errori
    Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given in C:\Users\giuliano\PhpstormProjects\catalogoMvc\lib rerie\dbCon.php on line 86

    Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in C:\Users\giuliano\PhpstormProjects\catalogoMvc\lib rerie\dbCon.php on line 99
    che non so come risolvere

  3. #3
    Moderatore di PHP L'avatar di Alhazred
    Registrato dal
    Oct 2003
    Messaggi
    12,503
    Per favore, leggi il regolamento e rispettalo, titoli generici come questo non sono ammessi.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.