I have a very complicated system which was opening and closing MySQLi connections every time it wanted to perform a query - of which it was doing about 40,000 of per given operation (inefficient, I know). I decided to pass the mysqli connection between functions, to prevent this open-and-close-repeatedly inefficiency.
My problem is: when a query fails I wanted to email myself the debug_backtrace()
, formatted in an easy-to-read format (so I wrap it in print_r()
). For some reason, I'm now getting a PHP warning that says print_r(): Property access is not allowed yet in... on line XXX
where line XXX simply reads addNotification("Backtrace: ".print_r(debug_backtrace(), true), "debug");
Is there some reason that print_r()
doesn't like debug_backtrace()
when one of the passed parameters in the backtrace is an mysqli_connect
object? Does the mysqli_connect lack a toString function?
EDIT After a little more research I've found that you CAN call print_r
or var_dump
on a mysqli_connect
object, but if that object is mysqli_close
d it causes this warning. If it is closed and unset
it is okay.