Workaround on SMF error mysql_real_escape_string() expects parameter 2 to be resource, boolean given in Subs-Db-mysql.php
Thu, 2011-06-23 07:53 | SergeChel
After updating SMF forum engine to version 2.0 I've noticed unnormal grow of error log with messages like:
mysql_real_escape_string() expects parameter 2 to be resource, boolean given in /.../smf/Sources/Subs-Db-mysql.php on line NNN
It looks like somehow the second parameter to this function changes from connection object to boolean value, due to the hosting configuration or source code bug, various versions can be found.
I did this temporary change to source code (find exact line number of /Sources/Subs-Db-mysql.php in your error log)
if (is_bool($connection)) { return sprintf('\'%1$s\'', mysql_real_escape_string($replacement)); } else { return sprintf('\'%1$s\'', mysql_real_escape_string($replacement, $connection)); }
Explanation: if $connection is boolean - do not use it as second parameter to function - default connection will be used instead.
Waiting for the fix from SMF team.