As during development, I set error_reporting(-1); , so I was sure that every syntax error would be shown by PHP. This, for example,
echo $ttt;
of course he gives
Notice: Undefined variable: ttt in ...
In this code snippet (part of some class representing a row in a mysql table):
public function delete(){ // ... $sth=$dbh->prepare('DELETE FROM tobjects WHERE IdObject=:id'); $sth->bindParam(':id',$this->fid,PDO::PARAM_INT); $sth->execute();
I was mistaken that now $this->fid , and the deletion did not happen, the error was not even noticed, and I spent a lot of time to find it.
$dbh set elsewhere as:
$dbh=new PDO("mysql:host=XXXX;port=XXXX;dbname=XXXX",$db_user, $db_password,array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'')); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
Am I doing something wrong or how is it possible that no error was given?
source share