Edit: added the PDO call.
This is the actual error:
Notice: Object of class PDOStatement could not be converted to int in Unknown on line 0
How can I in general find out which line is the correct line of the error/notice, since it is NOT line 0
?
I tried using register_tick_function echoing out file:line, which does not work, because the notice is always outputted at the end of my total output.
I am looking for a general debugging way, since I could not find any error in my class of that object.
// PHP PDO Standard
$db_server = 'mysql:host='.$this->db_host.';dbname='.$this->db_dbase;
try {
$this->db_connection = new PDO($db_server, $this->db_user, $this->db_pass);
$pdo_set = $this->db_connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, FALSE);
$pdo_set = $this->db_connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo_set = $this->db_connection->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
//DebugPrint($pdo_set, '$pdo_set');
} catch (PDOException $e) {
//print 'Error!: '.$e->getMessage().'<br/>';
die();
}
Finally, I found my own answer to my very own problem:
// doing PDO-sql, inserting session data, I ran into my problem.
$this->db_connection = new PDO(...);
$sql_query = "INSERT INTO ".$this->session_db_table." (...) VALUES (...)";
$sql_result = $this->db_connection->query($sql_query);
// This is the line (ideally named "0") from the notice:
return $sql_result;
return $sql_result
is throwing this notice:
"Notice: Object of class PDOStatement could not be converted to int in Unknown on line 0"
$sql_result
is an object
; return format expected seems to be boolean
.
So I removed this return
and the notice is now gone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With