No, I discovered that it stops excuting where message() is and gives that mySQL error, which doesn't make any sense.

After looking through the code the failure is happening on calls to the message funtion:

Like this one for logging in:
message($lang_login['Wrong user/pass'].' <a href="login.php?action=forget">'.$lang_login['Forgotten pass'].'</a>');

Or this one for forgotten password:
message($lang_login['Forget mail'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.');

Full error:
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Similar to this guy's problem: http://punbb.org/forums/viewtopic.php?id=9226

Could this be related to the MySQL version? Or magic quotes being on/off?

Any ideas?