views:

241

answers:

4

I've not come across an error like this before where Line 0 is referred to. Does it have a specific meaning, or is it simply that PHP was unable to determine the line number before something went wrong?

The full warning is:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /xxxxxx/text_editor.php on line 0

Although the warning appears, my MySQL connection appears intact and the application behaves as expected, aside from this message.

Additionally, I've got error_reporting(0) set, so I didn't expect to see any PHP warnings appear in the first place.

I'm running PHP 5.2.11 and have been unable to reproduce the error on other identical installations, nor when using PHP 5.2.9 or PHP 5.3.0. Given the above, can anyone shed any light on this for me?

Thanks, and if you need more information just let me know.

Rich

+1  A: 

Hi Rich,

I found this bug report: http://bugs.php.net/bug.php?id=32101

The author claims that:

When an exception is thrown inside an exception handler, a "exception thrown without stack frame in unknown on line 0" message is displayed.

I don't know if this may apply to your case, though. Are you catching the error in your text_editor.php?

Roberto Aloi
A: 

Hmm, Are you declaring the array return type?

mysql_fetch_array(data,array_type)

array_type

    * MYSQL_ASSOC - Associative array
    * MYSQL_NUM - Numeric array
    * MYSQL_BOTH - Default. Both associative and numeric array

Could be expecting the return type but has a default behavior.

Phill Pafford
A: 

The line 0 means that for some reason, PHP is unable to determine a better line number for where the problem occurs.

The underlying source of your trouble appears to be that what you are passing as the first (possibly only) argument to mysql_fetch_array() is not a valid result from mysql_query(). Did you check that mysql_query() itself returned successfully before going to fetch results with the result set?

The link provided by Phil Pafford says of the first parameter:

Required. Specifies which data pointer to use. The data pointer is the result from the mysql_query() function.

The same site says of mysql_query:

The mysql_query() function executes a query on a MySQL database.

This function returns the query handle for SELECT queries, TRUE/FALSE for other queries, or FALSE on failure.

Look at your error checking code. Every query to the database may fail - the DBMS may have crashed, if nothing else.

Jonathan Leffler
A: 

Thanks a lot for your answers! The file in question has rather a lot of mysql_queries so I was loath to go through each one of them without knowing exactly what the error meant. Luckily I didn't have to.

The reason that no line number was showing up in the PHP warning was because the file had been encoded using ionCube encoder - and line numbers had not been preserved. When I replaced the file with a non-encoded version for testing, suddenly the line number showed up in the error message and I could identify a simple typo within my MySQL query statement.

Thanks again all for your feedback, though!

Rich
Nice of you to leave the part about ionCube out of the question.
Reinis I.