致命错误 - 执行()php 5.2.13

I have PHP 5.2.3, apache2.x, mysql 5.x on a Linux machine. EVerything was working fine untill yesterday. This morning all of a sudden one of the php files started to throw "Fatal error: Call to a member function execute() on a non-object in". I use PDO (prepare, execute, close cursor etc). Have you ever come across this problem? does someone know a fix for this please.

Many thanks, R

As Alan says, the problem is probably that prepare is returning false rather than a PDOStatement. The best way to debug this is to turn warnings on. To do this, put this code right after you initialise PDO:

$db = new PDO();  // insert the following after this line
$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );

This will mean that a PHP warning will be raised by PDO when the prepare statement fails. This should contain information that will help you debug the problem.

Your prepare call is probably failing. This is probably due to a SQL statement that is not valid.

We would need to know exactly what library you are using to know more, but prepare is probably returning false instead of an object. Then when you try to call execute on the return value, you are trying to call it on false instead of an object, causing the error message you see.

If you echo or var_dump the value you are calling execute on, you will be able to see more details.