View Single Post

  #2 (permalink)  
Old 11-15-2004
Michael Fesser
 
Posts: n/a
Default Re: "Class '1' not found" - caused by mysql_fetch_object!

.oO(Sundial Services)

>I recently brought an old application out of mothballs and launched it under
>PHP5, only to get this message:
>
> Fatal Error: Class '1' not found
>
>It was clearly somehow an /execution/ time problem, because it did not
>appear on the first page I had linked to, all of which use the same
>includes. Even though it appears to be a compile-time error ...
>
>Anyhow, I solved it. The statement read:
>
> $r = mysql_fetch_object($DB, MYSQL_ASSOC);
>
>... and PHP (now) doesn't like that. "mysql_fetch_object" is now listed as
>having only one parameter.


IIRC it was always listed with only one parameter. A result type
different than MYSQL_ASSOC doesn't make sense when returning objects.

> [Note: "mysql_fetch_array" still has two!]


Yep, because it can return numeric or associative arrays.

>I consider this to be a PHP bug, however, because the compiler should have
>caught the fact that only one parameter is permitted to this function.


#20656 [Opn]: Feature Request: mysql_fetch_object as user defined class
http://www.mail-archive.com/php-bugs.../msg39049.html

>And
>at the very least it should have responded more cleanly. In retrospect, I
>speculate that the value of MYSQL_ASSOC is '1' and that perhaps there /is/
>an undocumented second parameter ...


Yep.

Micha
Reply With Quote