I can not insert into MariaDB table with my PHP script -


i moved mariadb, because since mysql 5.6 has been failing lot me.

mariadb works flawlessly but, in new project, cannot insert data database php script. can insert manually. have made no changes scripts working mysql.

the insert statement is:

insert participantes (nome, curso, email, equipe) values (:nome, :curso, :email, :equipe); 

and script should inserting is:

$stmt = $this->dbh->prepare($this->sql_insert); $nome = $participante->nome(); $curso = $participante->curso(); $email = $participante->email(); $equipe = $participante->equipe(); $stmt->bindparam(':nome', $nome); $stmt->bindparam(':curso', $curso); $stmt->bindparam(':email', $email); $stmt->bindparam(':equipe', $equipe); $stmt->execute(); 

the "participante" functions return data used, no problems. inside try/catch block, reports no exceptions.

my pdo class follows:

class connection extends pdo {     private $dsn = 'mysql:host=localhost;port=3307;dbname=dacu';     private $usr = 'dacu';     private $pwd = 'my password';      public $handle = null;      function __construct() {         try {             if ($this->handle == null) {                 $dbh = new pdo($this->dsn, $this->usr, $this->pwd);                 $dbh->setattribute(pdo::attr_errmode, pdo::errmode_exception);                 $this->handle = $dbh;                 return $this->handle;             }         }         catch (pdoexception $e) {             throw new exception('não foi possível conectar-se ao banco de dados: ' . $e->getmessage());         }         catch (exception $e) {             throw new exception('um erro não identificado ocorreu: ' . $e->getmessage());         }     } } 

and using controller->insert gives me:

warning: pdo::prepare(): sqlstate[00000]: no error: pdo constructor not called in c:\webserver\files\dacu\controller\equipescontroller.php on line 25 

i can post code on pastebin if necessary, ask.

check connection, try way, working fine:

    //first need connection mysql use , replace variables          try {           $dbh = new pdo('mysql:host=localhost;dbname='.$db_name.'', $user, $pass, array(             pdo::attr_persistent => true         ));         $dbh->setattribute(pdo::attr_errmode, pdo::errmode_exception);           } catch (pdoexception $e) {             print "error!: " . $e->getmessage() . "<br/>";             die();         }      //then insert variable          $sql  = 'insert encomendas (`nome`, `user`, `id`, `email`) ';         $sql .= 'values (:nome, :curso, :email, :equipe )';           $query = $dbh->prepare($sql);      //bindparam own variables          $query->bindparam(':nome', $vardonome, pdo::param_str);         $query->bindparam(':curso',  $vardocurso, pdo::param_str);         $query->bindparam(':email', $vardoemail, pdo::param_str);         $query->bindparam(':equipe', $vardaequipe, pdo::param_str);      //execute query          $query->execute()  ; 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -