"Class '1' not found" - caused by mysql_fetch_object!

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-15-2004
Sundial Services
 
Posts: n/a
Default "Class '1' not found" - caused by mysql_fetch_object!


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 ...


Reply With Quote
  #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
  #3 (permalink)  
Old 11-15-2004
2metre
 
Posts: n/a
Default Re: "Class '1' not found" - caused by mysql_fetch_object!

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?
Reply With Quote
  #4 (permalink)  
Old 11-15-2004
Michael Fesser
 
Posts: n/a
Default Re: "Class '1' not found" - caused by mysql_fetch_object!

.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
Reply With Quote
  #5 (permalink)  
Old 11-16-2004
2metre
 
Posts: n/a
Default Re: "Class '1' not found" - caused by mysql_fetch_object!

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).
Reply With Quote
  #6 (permalink)  
Old 11-16-2004
Michael Fesser
 
Posts: n/a
Default Re: "Class '1' not found" - caused by mysql_fetch_object!

.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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:19 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0