This is a discussion on "Class '1' not found" - caused by mysql_fetch_object! within the PHP Language forums, part of the PHP Programming Forums category; I recently brought an old application out of mothballs and launched it under PHP5, only to get this message: Fatal ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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. [Note: "mysql_fetch_array" still has two!] The error disappeared when the second parameter was removed. 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. 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 ... |
|
|||
|
.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 |
|
|||
|
Sundial Services wrote:
> 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. And and which compiler would that be? |
|
|||
|
.oO(2metre)
>Sundial Services wrote: > >> 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. And > >and which compiler would that be? PHP compiles the code before executing it. Micha |
|
|||
|
Michael Fesser wrote:
> .oO(2metre) > > >>Sundial Services wrote: >> >> >>>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. And >> >>and which compiler would that be? > > > PHP compiles the code before executing it. > > Micha I accept that the definition of compiler is open to debate. I was using the concept that 'compiling' infers converting the entire 'human-readable' source file into a 'machine-readable' executable file ( which can then be 'run'). By this definition, PHP is not a compiler. Using the definition favoured by you and the OP: With an interpreted language like PHP, if a function is never called or an object/class definition never used, it doesn't get compiled. With a proper compiler (by my earlier def), an unused function will be compiled, but may then be removed by a later optimisation stage (either in the compiler or the linker). |
|
|||
|
.oO(2metre)
>I accept that the definition of compiler is open to debate. > >I was using the concept that 'compiling' infers converting the entire >'human-readable' source file into a 'machine-readable' executable file ( >which can then be 'run'). By this definition, PHP is not a compiler. A compiler doesn't create executable files, that's what the linker does. A compiler translates one language/grammar into another, in case of PHP it translates the source code into a bytecode. This bytecode is then executed by an interpreter. >Using the definition favoured by you and the OP: >With an interpreted language like PHP, if a function is never called or >an object/class definition never used, it doesn't get compiled. I don't know, this would require to have a deeper look at PHP's core. Micha |
![]() |
| Thread Tools | |
| Display Modes | |
|
|