473,395 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

"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 ...
Jul 17 '05 #1
5 4128
.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/ph******.../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
Jul 17 '05 #2
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?
Jul 17 '05 #3
.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
Jul 17 '05 #4
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).
Jul 17 '05 #5
.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
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Chris Mantoulidis | last post by:
I was wondering if there was something like a "match" class in the std. By match class I mean something like a search tool. That is I will tell it in what text to search and WHAT to search for. The...
0
by: MIGUEL | last post by:
Hi all! Be patient because what I'm going to explain all of you it's more than very strange. I've developed a webservice project that contains two classes. One of them is going to act as a...
1
by: timbobd | last post by:
I have encountered a situation that I don't understand. When I call a sub of Friend scope (in an object with Friend scope), I am getting an error "Public member 'subname' not found in type...
11
by: Kimmo Laine | last post by:
I'm flipping my wig here, people. I'm using classes and making each class a file. when I'm including dependet classess, I use require_once to avoid multiple declarations - yet they happen. I put...
1
by: Carsten H. Pedersen | last post by:
I want to get a hold of the "calling" class of a method / constructor. An example would be as follows: public class A() { public A() { new B(); } } public class B() {
45
by: Gregory Petrosyan | last post by:
1) From 2.4.2 documentation: There are two new valid (semantic) forms for the raise statement: raise Class, instance raise instance 2) In python: >>> raise NameError Traceback (most recent...
2
by: Rymfax | last post by:
I have an application that will be used on both XP and Vista. One of the things this application needs to do is determine the exact operating system it is on. To get the correct "flavor" of Vista...
4
by: Christian Joergensen | last post by:
Hello I stumpled upon this "feature" during my work tonight, and found it a bit confusing: .... class C: .... foobar = 42 .... .... <class __main__.C at 0xb7cf735c>
36
by: Roedy Green | last post by:
The only browser I have encountered that supports <colgroup><col class="behold"></colgroup> to apply a CSS style to a whole column, is Microsoft Internet Explorer. I have been told it SHOULD NOT...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.