Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Class 'Model' not found

24 views
Skip to first unread message

M desinger

unread,
Aug 21, 2016, 10:35:33 AM8/21/16
to
Hello,please say how to fix error?

http://image.prntscr.com/image/7ed8056828874f37b2b62d2d9bc25d2d.png


12 line - $class = new Model();
Message has been deleted

M desinger

unread,
Aug 21, 2016, 10:43:14 AM8/21/16
to
Full code index.php



<?php



include './application/model/model.php';
include './application/config/system.php';
include './application/config/language.lv.php';




12 line ---> $class = new Model();

J.O. Aho

unread,
Aug 21, 2016, 12:08:33 PM8/21/16
to
Are you sure it's called Model and nothing else like model?

--

//Aho

Christoph M. Becker

unread,
Aug 21, 2016, 1:35:50 PM8/21/16
to
PHP is case-insensitive wrt. class names, so if the class would have
been defined as `model` the code would work nonetheless. If the name is
something else altogether, that would cause issues, though.

Another possibility is that a file couldn't be included. Check the
error_logs, or consider to use `require` instead of `include`.

--
Christoph M. Becker

Thomas 'PointedEars' Lahn

unread,
Aug 22, 2016, 2:57:02 PM8/22/16
to
The “include” should be “require_once”, so that you get a “Fatal error” if
the inclusion fails, the error message telling you *why* “require_once”
failed. “require_once” instead of “require” includes those files only once,
which avoids all sorts of problems.

In any case, the leading “./” is superfluous.

Finally, one uses namespaces and autoloading these days; *all* kinds of
includes (include, include_once, require, and require_once) are deprecated
for loading class files like model.php. RTFM.

--
PointedEars
Zend Certified PHP Engineer
<http://www.zend.com/en/yellow-pages/ZEND024953> | Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.

Jerry Stuckle

unread,
Aug 22, 2016, 7:08:45 PM8/22/16
to
On 8/22/2016 2:56 PM, the troll Thomas 'Pointed Head' Lahn wrote:
> M desinger wrote:
>
>> Full code index.php
>>
>> <?php
>>
>> include './application/model/model.php';
>> include './application/config/system.php';
>> include './application/config/language.lv.php';
>>
>> 12 line ---> $class = new Model();
>
> The “include” should be “require_once”, so that you get a “Fatal error” if
> the inclusion fails, the error message telling you *why* “require_once”
> failed. “require_once” instead of “require” includes those files only once,
> which avoids all sorts of problems.
>
> In any case, the leading “./” is superfluous.
>
> Finally, one uses namespaces and autoloading these days; *all* kinds of
> includes (include, include_once, require, and require_once) are deprecated
> for loading class files like model.php. RTFM.
>

You've obviously not had the autoloading function pick up the wrong
version of a class. But that's not surprising from you. You have
repeatedly shown you have no concept of good coding techniques, and have
probably never had two classes of ANY name on your system.


--
==================
Remove the "x" from my email address
Jerry Stuckle
jstu...@attglobal.net
==================

Matthew Carter

unread,
Aug 23, 2016, 1:23:10 AM8/23/16
to
Why would you have 2 identically named classes in the same namespace (if
different namespaces, alias them)?

If you're actually referring to 2 versions of the same class at
different points in time, why not a VCS?

--
Matthew Carter (m...@ahungry.com)
http://ahungry.com

Jerry Stuckle

unread,
Aug 23, 2016, 8:07:54 AM8/23/16
to
Because you loaded two different packages, both with the same class
name. Or you're running two different versions of software on the same
machine.

It's not at all uncommon when you're running multiple sites on one server.

Thomas 'PointedEars' Lahn

unread,
Aug 27, 2016, 8:27:05 AM8/27/16
to
Jerry Stuckle wrote:

> On 8/23/2016 1:23 AM, Matthew Carter wrote:
>> Jerry Stuckle <jstu...@attglobal.net> writes:
>>> You've obviously not had the autoloading function pick up the wrong
>>> version of a class. But that's not surprising from you. You have
>>> repeatedly shown you have no concept of good coding techniques, and have
>>> probably never had two classes of ANY name on your system.
>>
>> Why would you have 2 identically named classes in the same namespace (if
>> different namespaces, alias them)?
^^^^^^^^^^
>> If you're actually referring to 2 versions of the same class at
>> different points in time, why not a VCS?
>
> Because you loaded two different packages, both with the same class
> name.

You can have the same class name in the same namespace in two different
*files*.

But you _can not_ have that in the same PHP program, not even as includes.
It is not possible to redeclare classes, and you cannot undeclare/delete a
class. So it is irrelevant if you use an autoloader in that case. For
example,

require_once 'Foo/Bar.php';
require_once 'Baz/Bar.php';

where each Bar.php contains

class Bar
{
// …
}

results in “PHP Fatal error: Cannot redeclare class Bar in … on line …”.
No “use” statement can prevent that because the class has to be loaded
*before* it can be aliased. Which is why interoperable classes are declared
in their own namespace these days (formerly, prefixes were used to avoid
name collisions instead).

As for the same class in different namespaces, I have marked the important
part in Matthew’s posting. For further reference:

<http://php.net/manual/en/language.namespaces.importing.php>

IOW:

/* or: use Foo\Bar\Baz */;
use Foo\Bar\Baz as Bla;

use Foo\Bar2\Baz as Blub;

Then there could be a “Foo/Bar/Baz.php” that contains

namespace Foo\Bar;

class Baz
{
// …
}

and a “Foo/Bar2/Baz.php” that contains

namespace Foo\Bar2;

class Baz
{
// …
}

and (with a suitable autoloader) you could just write

/* or “new Baz()”, see above */
new Bla();

new Blub();

> Or you're running two different versions of software on the same machine.
> It's not at all uncommon when you're running multiple sites on one server.

If only you knew what you are talking about.

Different sites on the same machine, each using different versions of the
same class, perhaps in the same namespace, would either use *different*
autoloaders each (to avoid loading classes and their dependencies manually).
This can be as simple as adapting the include_path per site, or as
complicated as using different “require_once” statements (with different
paths) to load the correct autoloader.

Or they would use one or more namespace-and-path-aware autoloaders. It is
possible to register *several* autoloaders, each only attempting to autoload
the classes that are in its namespace. Simple example:

/* Library 1 code */

function autoload_lib1 ($class)
{
echo "autoload_lib1: autoloading $class ...\n";
if (strpos($class, "Lib1\\") !== 0)
{
trigger_error("DEBUG: autoload_lib1: autoloading of $class rejected: "
. " Not in our namespace\n", E_USER_NOTICE);
return;
}

/* Use include_once for the example only */
include_once "lib1path" . DIRECTORY_SEPARATOR
. str_replace("\\", DIRECTORY_SEPARATOR,
str_replace("Lib1\\", "", $class))
. ".php";
}

spl_autoload_register("\\autoload_lib1", true);


/* Library 2 code */

function autoload_lib2 ($class)
{
echo "autoload_lib2: autoloading $class ...\n";
if (strpos($class, "Lib2\\") !== 0)
{
trigger_error("DEBUG: autoload_lib1: autoloading of $class rejected: "
. " Not in our namespace\n", E_USER_NOTICE);
return;
}

/* Use include_once for the example only */
include_once "lib2path" . DIRECTORY_SEPARATOR
. str_replace("\\", DIRECTORY_SEPARATOR,
str_replace("Lib2\\", "", $class))
. ".php";
}

spl_autoload_register("\\autoload_lib2", true);


/* User code */

new Lib1\Foo1();

[Usually it does not make sense to use two versions of the same library
simultaneously because of different dependencies, and because the newer
version can do more than the older one. However, it is probably a good idea
to always write an autoloader so that it does not attempt to autoload
classes that are "out of its jurisdiction".]

It is also possible to have *one* autoloader that handles *several*
namespaces and maps namespaces to paths correctly. Simplest (as is,
*unsafe*) case:

function autoload_all ($class)
{
require_once str_replace("\\", DIRECTORY_SEPARATOR, $class) . ".php";
}

spl_autoload_register("\\autoload_all", true);

[Note that the autoloader can be in a namespace itself, which reduces the
risk of namespace collisions for *its* declaration. That also makes it
easier to autoload only the classes "in the autoloader’s jurisdiction".]

IOW, the problems that you are presuming simply *do* *not* *exist*.

Jerry Stuckle

unread,
Aug 27, 2016, 10:13:23 AM8/27/16
to
<snip bullshit that requires system-specific code that no one in their
right mind (which leaves out Pointed Head) would implement on a
production system>

Whoosh. That's the sound of the discussion going right over your head.

But that's not unusual for you.

Thomas 'PointedEars' Lahn

unread,
Aug 27, 2016, 8:12:08 PM8/27/16
to
Jerry Stuckle wrote:

> <snip bullshit that requires system-specific code that no one in their
> right mind (which leaves out Pointed Head) would implement on a
> production system>

There is nothing system-specific in this *example* code. In particular,
DIRECTORY_SEPARATOR is _not_ system-specific.

> Whoosh. That's the sound of the discussion going right over your head.

No, autoloading goes well over *your* head. Smart people use autoloaders
these days. It is even in the PHP Coding Standards. I strongly suggest
you either catch up or shut up.

Jerry Stuckle

unread,
Aug 27, 2016, 8:32:28 PM8/27/16
to
On 8/27/2016 8:12 PM, Thomas 'Pointed Head' Lahn wrote:
> Jerry Stuckle wrote:
>
>> <snip bullshit that requires system-specific code that no one in their
>> right mind (which leaves out Pointed Head) would implement on a
>> production system>
>
> There is nothing system-specific in this *example* code. In particular,
> DIRECTORY_SEPARATOR is _not_ system-specific.
>
>> Whoosh. That's the sound of the discussion going right over your head.
>
> No, autoloading goes well over *your* head. Smart people use autoloaders
> these days. It is even in the PHP Coding Standards. I strongly suggest
> you either catch up or shut up.
>

Not at all. But you have no idea what kind of problems it can cause.

As for the PHP coding standards - good programmers know just how bad
those "standards" are. Did you help write them? They look like your
work - they're that bad.

I strongly suggest you go back to ditch digging - if you ever figure out
which end of the shovel to use. But I doubt you'll ever figure that
out, either.

Matthew Carter

unread,
Aug 28, 2016, 12:00:12 AM8/28/16
to
Great explanation, a wonderful reference for anyone needing to
understand these topics better.

Jerry Stuckle

unread,
Aug 28, 2016, 8:40:33 AM8/28/16
to
And it solves no problem. These problems *do exist* in real life. But
Pointed Head is well known in multiple newsgroups as a know-nothing troll.

Thomas 'PointedEars' Lahn

unread,
Aug 30, 2016, 5:35:35 AM8/30/16
to
Matthew Carter wrote:

> Thomas 'PointedEars' Lahn <Point...@web.de> writes:
>> Different sites on the same machine, each using different versions of the
>> same class, perhaps in the same namespace, would either use *different*
>> autoloaders each (to avoid loading classes and their dependencies
>> manually). This can be as simple as adapting the include_path per site,
>> or as complicated as using different “require_once” statements (with
>> different paths) to load the correct autoloader.
>>
>> Or they would use one or more namespace-and-path-aware autoloaders. It
>> is possible to register *several* autoloaders, each only attempting to
>> autoload the classes that are in its namespace. Simple example:
>> […]
>> [Usually it does not make sense to use two versions of the same library
>> simultaneously because of different dependencies, and because the newer
>> version can do more than the older one. However, it is probably a good
>> idea to always write an autoloader so that it does not attempt to
>> autoload classes that are "out of its jurisdiction".]
>>
>> It is also possible to have *one* autoloader that handles *several*
>> namespaces and maps namespaces to paths correctly. Simplest (as is,
>> *unsafe*) case:
>>
>> function autoload_all ($class)
>> {
>> require_once str_replace("\\", DIRECTORY_SEPARATOR, $class) . ".php";
>> }
>>
>> spl_autoload_register("\\autoload_all", true);
>>
>> [Note that the autoloader can be in a namespace itself, which reduces the
>> risk of namespace collisions for *its* declaration. That also makes it
>> easier to autoload only the classes "in the autoloader’s jurisdiction".]
>>
>> IOW, the problems that you are presuming simply *do* *not* *exist*.
>
> Great explanation, a wonderful reference for anyone needing to
> understand these topics better.

Thank you very much.

In order not to be misunderstood, I want to clarify and emphasize that
I meant “to *load* two versions of the same library (*written in PHP*)” when
I wrote “to use two versions of the same library”. And when I wrote “user”,
I meant the user of code written in PHP (i.e. a PHP programmer), not the end
user.

“Loading” is different to “using” because AISB there can be two (or more)
versions of a library (written in PHP) on the storage device (“using”), to
be used by different programs/sites accessing that storage device, but you
usually need not (and do not want to or simply cannot, due to the
aforementioned namespace conflicts) *load* all of them at the same time, in
the same PHP program.

One also has to keep in mind that (AISB) the include statements “include”,
“include_once”, “require”, and “require_once” observe the “include_path”
setting. And the autoloader can determine its location in the filesystem
with the __FILE__ and __DIR__ magic constants [0]. So if the library path
or the library repository path is in the include_path (which can be set in
php.ini, in Web server configuration files, and even on runtime by default
[1]), everything follows from there.

Usually, the only thing that has to be and should be loaded via
“require_once” *in user code* is the autoloader itself. However, dependency
managers like Composer [2] can set that up when installing a library in an
application as a package.

The DIRECTORY_SEPARATOR in the autoloader code removes the final dependency
on the setup of the server system because it is a constant that is set to
what is supported by the operating system that PHP was compiled for (and
therefore is supposed to be running on). [3]

_________
[0] <http://php.net/manual/en/language.constants.predefined.php>
[1] <http://php.net/set_include_path>
[2] <https://getcomposer.org/>
[3] <http://php.net/manual/en/dir.constants.php>

(While the documentation confusingly says there that an extension
has to be installed for those contants to be available,
<http://php.net/manual/en/dir.installation.php> emphasizes that
“There is no installation needed to use these functions; they are part
of the PHP core.”)

Thomas 'PointedEars' Lahn

unread,
Aug 30, 2016, 5:39:58 AM8/30/16
to
It solves the problem that dependencies have to be resolved manually, which
was the problem of the OP.

> These problems *do exist* in real life.

Only to the incompetent.

Jerry Stuckle

unread,
Aug 30, 2016, 7:41:41 AM8/30/16
to
On 8/30/2016 5:39 AM, the troll Thomas 'Pointed Head' Lahn wrote:
> Jerry Stuckle wrote:
>
>> On 8/28/2016 12:00 AM, Matthew Carter wrote:
>>> Thomas 'PointedEars' Lahn <Point...@web.de> writes:
>>>> IOW, the problems that you are presuming simply *do* *not* *exist*.
>>> Great explanation, a wonderful reference for anyone needing to
>>> understand these topics better.
>>
>> And it solves no problem.
>
> It solves the problem that dependencies have to be resolved manually, which
> was the problem of the OP.
>
>> These problems *do exist* in real life.
>
> Only to the incompetent.
>

It doesn't solve the problem of multiple classes with the same name.
It's all too easy to load the wrong class.

But someone as incompetent as you are wouldn't know about testing and
migrating versions of code. You've never had a successful project in
your life. Just like you've never been able to be a successful ditch
digger because you don't know which end of the shovel to use.

You are just an incompetent troll - well known as one in multiple
newsgroups.

Thomas 'PointedEars' Lahn

unread,
Aug 30, 2016, 8:41:52 AM8/30/16
to
Jerry Stuckle wrote:

> On 8/30/2016 5:39 AM, the troll Thomas 'Pointed Head' Lahn wrote:
>> Jerry Stuckle wrote:
>>> On 8/28/2016 12:00 AM, Matthew Carter wrote:
>>>> Thomas 'PointedEars' Lahn <Point...@web.de> writes:
>>>>> IOW, the problems that you are presuming simply *do* *not* *exist*.
>>>> Great explanation, a wonderful reference for anyone needing to
>>>> understand these topics better.
>>> And it solves no problem.
>>
>> It solves the problem that dependencies have to be resolved manually,
>> which was the problem of the OP.
>>
>>> These problems *do exist* in real life.
>> Only to the incompetent.
>
> It doesn't solve the problem of multiple classes with the same name.

That was _not_ the problem of the OP. It was an unfounded assumption by
“J.O. Aho” who did not read the OP carefully, too. The OP got

| Fatal error: Class 'Model' not found in /var/www/index.php on line 12

(which arguably should have been posted as plain text instead of a URL of an
image)

for

$class = new Model();

So the include must have been wrong. Had an autoloader been used (or maybe
it had, but incorrectly; who knows), an include would not have been
necessary, the file path would have not mattered, the include would not have
failed, and the class could have been loaded. *IOW, dependencies would not
have had to be resolved manually, with the potential of failure.*

> It's all too easy to load the wrong class.

AISB, this is only a problem for the incompetent.

One simply does not have *multiple* classes with the *same* name in the
*same* namespace loaded in the *same* program/application, because *PHP does
not allow it* – autoloader or not. Because of this, one also simply does
not have *multiple* classes with the *same* name in the *same* directory to
begin with. Where multiple versions are available, they are supposed to be
in different directories or different namespaces, and in different revisions
of a VCS, to be checked out on an as-needed basis (as Matthew already
indicated).

Only the *utterly incompetent* would do otherwise.

And if one uses an autoloader for loading classes (which one should), the
problem disappears in a puff of program logic by choosing the right one, by
not choosing more than one, or – this is up to the class author; again, a
matter of competence – to register the autoloader in such a way that there
is no namespace conflict (as I explained before).

Please stop wasting our precious time by projecting your incompetence.

Jerry Stuckle

unread,
Aug 30, 2016, 9:02:43 AM8/30/16
to
On 8/30/2016 8:41 AM, the well-known troll Thomas 'Pointed Head' Lahn wrote:
> Jerry Stuckle wrote:
>
>> On 8/30/2016 5:39 AM, the troll Thomas 'Pointed Head' Lahn wrote:
>>> Jerry Stuckle wrote:
>>>> On 8/28/2016 12:00 AM, Matthew Carter wrote:
>>>>> Thomas 'PointedEars' Lahn <Point...@web.de> writes:
>>>>>> IOW, the problems that you are presuming simply *do* *not* *exist*.
>>>>> Great explanation, a wonderful reference for anyone needing to
>>>>> understand these topics better.
>>>> And it solves no problem.
>>>
>>> It solves the problem that dependencies have to be resolved manually,
>>> which was the problem of the OP.
>>>
>>>> These problems *do exist* in real life.
>>> Only to the incompetent.
>>
>> It doesn't solve the problem of multiple classes with the same name.
>
> That was _not_ the problem of the OP. It was an unfounded assumption by
> “J.O. Aho” who did not read the OP carefully, too. The OP got
>

No, it is a problem caused by your "solution". And an even bigger
problem than the ops, because it is not evident.

> | Fatal error: Class 'Model' not found in /var/www/index.php on line 12
>
> (which arguably should have been posted as plain text instead of a URL of an
> image)
>
> for
>
> $class = new Model();
>
> So the include must have been wrong. Had an autoloader been used (or maybe
> it had, but incorrectly; who knows), an include would not have been
> necessary, the file path would have not mattered, the include would not have
> failed, and the class could have been loaded. *IOW, dependencies would not
> have had to be resolved manually, with the potential of failure.*
>

And potentially cause even worse problems.

>> It's all too easy to load the wrong class.
>
> AISB, this is only a problem for the incompetent.
>
> One simply does not have *multiple* classes with the *same* name in the
> *same* namespace loaded in the *same* program/application, because *PHP does
> not allow it* – autoloader or not. Because of this, one also simply does
> not have *multiple* classes with the *same* name in the *same* directory to
> begin with. Where multiple versions are available, they are supposed to be
> in different directories or different namespaces, and in different revisions
> of a VCS, to be checked out on an as-needed basis (as Matthew already
> indicated).
>
> Only the *utterly incompetent* would do otherwise.
>

Well, then I guess there are millions of "incompetent" programmers out
there, according to your definition. Because programmers all over the
world have multiple versions of software on their systems.

For instance, when you upgrades a CMS to a new version, you don't
migrate dozens of websites on the same server using it all at once. You
back up one, migrate it and test. If it works, you make the migrated
version live. Then repeat the process for other web sites on that server.

And the different versions of the CMS all have the same class names and
the same namespaces. And they are all live on the system at the same
time. Keeping them in different directories doesn't work if you're
using an autoloader. Only one of the versions will load the correct
files; the others will load files belonging to a different version.

Staged upgrades like this are used all over the world. So I guess all
of those people are "incompetent". At least according to you they are.
Maybe it's YOU that's incompetent. No - forget the "maybe".

> And if one uses an autoloader for loading classes (which one should), the
> problem disappears in a puff of program logic by choosing the right one, by
> not choosing more than one, or – this is up to the class author; again, a
> matter of competence – to register the autoloader in such a way that there
> is no namespace conflict (as I explained before).
>

And create more, even harder to find problems.

> Please stop wasting our precious time by projecting your incompetence.
>

Yes, please do. Your total lack of understanding of how the real world
operates is once again showing. As is your total incompetence.

But once again, that is well-known my people in multiple newsgroups. So
that's no surprise.

Thomas 'PointedEars' Lahn

unread,
Aug 30, 2016, 9:36:09 AM8/30/16
to
Jerry Stuckle wrote:

> On 8/30/2016 8:41 AM, the well-known troll Thomas 'Pointed Head' Lahn
^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
It takes one to know one.

> wrote:
>> Jerry Stuckle wrote:
>>> On 8/30/2016 5:39 AM, the troll Thomas 'Pointed Head' Lahn wrote:
>>>> Jerry Stuckle wrote:
>>>>> On 8/28/2016 12:00 AM, Matthew Carter wrote:
>>>>>> Thomas 'PointedEars' Lahn <Point...@web.de> writes:
>>>>>>> IOW, the problems that you are presuming simply *do* *not* *exist*.
>>>>>> Great explanation, a wonderful reference for anyone needing to
>>>>>> understand these topics better.
>>>>> And it solves no problem.
>>>>
>>>> It solves the problem that dependencies have to be resolved manually,
>>>> which was the problem of the OP.
>>>>
>>>>> These problems *do exist* in real life.
>>>> Only to the incompetent.
>>>
>>> It doesn't solve the problem of multiple classes with the same name.
>>
>> That was _not_ the problem of the OP. It was an unfounded assumption by
>> “J.O. Aho” who did not read the OP carefully, too. The OP got
>
> No, it is a problem caused by your "solution".

Nonsense.

> And an even bigger problem than the ops, because it is not evident.

You have no clue what you are talking about. Different to the OP, an
autoloader would use “require_once” *by definition* (I said in my first
followup that using “require_once” instead of “include” in the original code
is the first step in analysing the problem; Christoph said “require”
before). “require_once” generates a “Fatal error” if inclusion fails. The
stack trace produced and a potential custom exception shows the problem and
where it originated.

>> […] *IOW, [with an autoloader] dependencies would not have had to be
>> resolved manually, with the potential of failure.*
>
> And potentially cause even worse problems.

In your wet dreams.

>>> It's all too easy to load the wrong class.
>>
>> AISB, this is only a problem for the incompetent.
>>
>> One simply does not have *multiple* classes with the *same* name in the
>> *same* namespace loaded in the *same* program/application, because *PHP
>> does not allow it* – autoloader or not. Because of this, one also simply
>> does not have *multiple* classes with the *same* name in the *same*
>> directory to begin with. Where multiple versions are available, they are
>> supposed to be in different directories or different namespaces, and in
>> different revisions of a VCS, to be checked out on an as-needed basis (as
>> Matthew already indicated).
>>
>> Only the *utterly incompetent* would do otherwise.
>
> Well, then I guess there are millions of "incompetent" programmers out
> there, according to your definition.

There probably are (there are always millions of people incompetent in a
field against a few competent ones), but not according to the definition
above.

You simply cannot read carefully. Because you do not want to.

> Because programmers all over the world have multiple versions of software
> on their systems.

The part that you *still* do seem to get is that there is a difference
between having several versions, using several versions, and loading several
versions. You "overlooked" “different directories”, too.

Enough of your hot air. Put your money where your big mouth is. Unless you
can present an easily reproducible, *real-world* example – and I mean
*files* of *PHP source code*, at least one program file and two class
files –, where *properly* using an autoloader in a *proper* setup (as I
described) would cause *new* problems that would *not* exist without using
an autoloader (you need to describe those problems in sufficient detail,
then; no wild assumptions), EOD for me.

Jerry Stuckle

unread,
Aug 30, 2016, 10:39:19 AM8/30/16
to
On 8/30/2016 9:36 AM, the well known troll Thomas 'Pointed Head' Lahn wrote:
> Jerry Stuckle wrote:
>
>> On 8/30/2016 8:41 AM, the well-known troll Thomas 'Pointed Head' Lahn
> ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
> It takes one to know one.
>

Your typical 3rd grade response. That's about your speed!

>> wrote:
>>> Jerry Stuckle wrote:
>>>> On 8/30/2016 5:39 AM, the troll Thomas 'Pointed Head' Lahn wrote:
>>>>> Jerry Stuckle wrote:
>>>>>> On 8/28/2016 12:00 AM, Matthew Carter wrote:
>>>>>>> Thomas 'PointedEars' Lahn <Point...@web.de> writes:
>>>>>>>> IOW, the problems that you are presuming simply *do* *not* *exist*.
>>>>>>> Great explanation, a wonderful reference for anyone needing to
>>>>>>> understand these topics better.
>>>>>> And it solves no problem.
>>>>>
>>>>> It solves the problem that dependencies have to be resolved manually,
>>>>> which was the problem of the OP.
>>>>>
>>>>>> These problems *do exist* in real life.
>>>>> Only to the incompetent.
>>>>
>>>> It doesn't solve the problem of multiple classes with the same name.
>>>
>>> That was _not_ the problem of the OP. It was an unfounded assumption by
>>> “J.O. Aho” who did not read the OP carefully, too. The OP got
>>
>> No, it is a problem caused by your "solution".
>
> Nonsense.
>

Well, of course, such a problem would never occur in a "Hello, World!"
program, which is all you're capable of writing, so you wouldn't know.

>> And an even bigger problem than the ops, because it is not evident.
>
> You have no clue what you are talking about. Different to the OP, an
> autoloader would use “require_once” *by definition* (I said in my first
> followup that using “require_once” instead of “include” in the original code
> is the first step in analysing the problem; Christoph said “require”
> before). “require_once” generates a “Fatal error” if inclusion fails. The
> stack trace produced and a potential custom exception shows the problem and
> where it originated.
>

Oh, I know *exactly* what I'm talking about. But you weren't telling
him to use require_once. You were telling him to use the autoloader.
And defending your position.

>>> […] *IOW, [with an autoloader] dependencies would not have had to be
>>> resolved manually, with the potential of failure.*
>>
>> And potentially cause even worse problems.
>
> In your wet dreams.
>

Another 3rd grade response. How typical of a troll.

>>>> It's all too easy to load the wrong class.
>>>
>>> AISB, this is only a problem for the incompetent.
>>>
>>> One simply does not have *multiple* classes with the *same* name in the
>>> *same* namespace loaded in the *same* program/application, because *PHP
>>> does not allow it* – autoloader or not. Because of this, one also simply
>>> does not have *multiple* classes with the *same* name in the *same*
>>> directory to begin with. Where multiple versions are available, they are
>>> supposed to be in different directories or different namespaces, and in
>>> different revisions of a VCS, to be checked out on an as-needed basis (as
>>> Matthew already indicated).
>>>
>>> Only the *utterly incompetent* would do otherwise.
>>
>> Well, then I guess there are millions of "incompetent" programmers out
>> there, according to your definition.
>
> There probably are (there are always millions of people incompetent in a
> field against a few competent ones), but not according to the definition
> above.
>

These guys keep hundreds of millions of websites running daily. They
are much more competent than you are. But you're right - you probably
do know a lot of incompetent programmers - but no competent ones (except
a few on this newsgroup that you continually argue with).

> You simply cannot read carefully. Because you do not want to.
>

I can read quite well.

>> Because programmers all over the world have multiple versions of software
>> on their systems.
>
> The part that you *still* do seem to get is that there is a difference
> between having several versions, using several versions, and loading several
> versions. You "overlooked" “different directories”, too.
>

Nope, classes are often in a common directory, shared across multiple
different websites. But the code accessing them can be individual to
the websites. When using the autoloader, new versions will try to load
the old version's directory.

> Enough of your hot air. Put your money where your big mouth is. Unless you
> can present an easily reproducible, *real-world* example – and I mean
> *files* of *PHP source code*, at least one program file and two class
> files –, where *properly* using an autoloader in a *proper* setup (as I
> described) would cause *new* problems that would *not* exist without using
> an autoloader (you need to describe those problems in sufficient detail,
> then; no wild assumptions), EOD for me.
>
>

I don't need to prove ANYTHING to a troll like you. Just the fact
*NONE* of the commercial (paid and free) PHP products out there use
autoloader shows competent programmers understand the problems
associated with it. And you have proven you don't.

But no surprise there. Your 3rd grade mind is incapable of
understanding anything beyond "wet dreams".

M desinger

unread,
Aug 30, 2016, 5:26:16 PM8/30/16
to
This my model file.
<?php
/*
*/
class DB
{
private $db = null;
public $filter;
static $inst = null;
public static $counter = 0;

/**
* Allow the class to send admins a message alerting them to errors
* on production sites
*
* @access public
* @param string $error
* @param string $query
* @return mixed
*/
public function log_db_errors( $error, $query )
{
$message = '<p>Error at '. date('Y-m-d H:i:s').':</p>';
$message .= '<p>Query: '. htmlentities( $query ).'<br />';
$message .= 'Error: ' . $error;
$message .= '</p>';
if( defined( 'SEND_ERRORS_TO' ) )
{
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: Admin <'.SEND_ERRORS_TO.'>' . "\r\n";
$headers .= 'From: Yoursite <system@'.$_SERVER['SERVER_NAME'].'.com>' . "\r\n";
mail( SEND_ERRORS_TO, 'Database Error', $message, $headers );
}
else
{
trigger_error( $message );
}
if( !defined( 'DISPLAY_DEBUG' ) || ( defined( 'DISPLAY_DEBUG' ) && DISPLAY_DEBUG ) )
{
echo $message;
}
}


public function __construct($db) {
mb_internal_encoding( 'UTF-8' );
mb_regex_encoding( 'UTF-8' );
mysqli_report( MYSQLI_REPORT_STRICT );
try {
$this->db = $db;
$this->db->set_charset( "utf8" );
} catch ( Exception $e ) {
die( 'Unable to connect to database' );
}
}
public function __destruct()
{
if( $this->db)
{
$this->disconnect();
}
}
/**
* Sanitize user data
*
* Example usage:
* $user_name = $database->filter( $_POST['user_name'] );
*
* Or to filter an entire array:
* $data = array( 'name' => $_POST['name'], 'email' => 'em...@address.com' );
* $data = $database->filter( $data );
*
* @access public
* @param mixed $data
* @return mixed $data
*/
public function filter( $data )
{
if( !is_array( $data ) )
{
$data = $this->db->real_escape_string( $data );
$data = trim( htmlentities( $data, ENT_QUOTES, 'UTF-8', false ) );
}
else
{
//Self call function to sanitize array data
$data = array_map( array( $this, 'filter' ), $data );
}
return $data;
}


/**
* Extra function to filter when only mysqli_real_escape_string is needed
* @access public
* @param mixed $data
* @return mixed $data
*/
public function escape( $data )
{
if( !is_array( $data ) )
{
$data = $this->db->real_escape_string( $data );
}
else
{
//Self call function to sanitize array data
$data = array_map( array( $this, 'escape' ), $data );
}
return $data;
}


/**
* Normalize sanitized data for display (reverse $database->filter cleaning)
*
* Example usage:
* echo $database->clean( $data_from_database );
*
* @access public
* @param string $data
* @return string $data
*/
public function clean( $data )
{
$data = stripslashes( $data );
$data = html_entity_decode( $data, ENT_QUOTES, 'UTF-8' );
$data = nl2br( $data );
$data = urldecode( $data );
return $data;
}


/**
* Determine if common non-encapsulated fields are being used
*
* Example usage:
* if( $database->db_common( $query ) )
* {
* //Do something
* }
* Used by function exists
*
* @access public
* @param string
* @param array
* @return bool
*
*/
public function db_common( $value = '' )
{
if( is_array( $value ) )
{
foreach( $value as $v )
{
if( preg_match( '/AES_DECRYPT/i', $v ) || preg_match( '/AES_ENCRYPT/i', $v ) || preg_match( '/now()/i', $v ) )
{
return true;
}
else
{
return false;
}
}
}
else
{
if( preg_match( '/AES_DECRYPT/i', $value ) || preg_match( '/AES_ENCRYPT/i', $value ) || preg_match( '/now()/i', $value ) )
{
return true;
}
}
}


/**
* Perform queries
* All following functions run through this function
*
* @access public
* @param string
* @return string
* @return array
* @return bool
*
*/
public function query( $query )
{
$full_query = $this->db->query( $query );
if( $this->db->error )
{
$this->log_db_errors( $this->db->error, $query );
return false;
}
else
{
return true;
}
}


/**
* Determine if database table exists
* Example usage:
* if( !$database->table_exists( 'checkingfortable' ) )
* {
* //Install your table or throw error
* }
*
* @access public
* @param string
* @return bool
*
*/
public function table_exists( $name )
{
self::$counter++;
$check = $this->db->query( "SELECT 1 FROM $name" );
if($check !== false)
{
if( $check->num_rows > 0 )
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}


/**
* Count number of rows found matching a specific query
*
* Example usage:
* $rows = $database->num_rows( "SELECT id FROM users WHERE user_id = 44" );
*
* @access public
* @param string
* @return int
*
*/
public function num_rows( $query )
{
self::$counter++;
$num_rows = $this->db->query( $query );
if( $this->db->error )
{
$this->log_db_errors( $this->db->error, $query );
return $this->db->error;
}
else
{
return $num_rows->num_rows;
}
}


/**
* Run check to see if value exists, returns true or false
*
* Example Usage:
* $check_user = array(
* 'user_email' => 'some...@gmail.com',
* 'user_id' => 48
* );
* $exists = $database->exists( 'your_table', 'user_id', $check_user );
*
* @access public
* @param string database table name
* @param string field to check (i.e. 'user_id' or COUNT(user_id))
* @param array column name => column value to match
* @return bool
*
*/
public function exists( $table = '', $check_val = '', $params = array() )
{
self::$counter++;
if( empty($table) || empty($check_val) || empty($params) )
{
return false;
}
$check = array();
foreach( $params as $field => $value )
{
if( !empty( $field ) && !empty( $value ) )
{
//Check for frequently used mysql commands and prevent encapsulation of them
if( $this->db_common( $value ) )
{
$check[] = "$field = $value";
}
else
{
$check[] = "$field = '$value'";
}
}
}
$check = implode(' AND ', $check);
$rs_check = "SELECT $check_val FROM ".$table." WHERE $check";
$number = $this->num_rows( $rs_check );
if( $number === 0 )
{
return false;
}
else
{
return true;
}
}


/**
* Return specific row based on db query
*
* Example usage:
* list( $name, $email ) = $database->get_row( "SELECT name, email FROM users WHERE user_id = 44" );
*
* @access public
* @param string
* @param bool $object (true returns results as objects)
* @return array
*
*/
public function get_row( $query, $object = false )
{
self::$counter++;
$row = $this->db->query( $query );
if( $this->db->error )
{
$this->log_db_errors( $this->db->error, $query );
return false;
}
else
{
$r = ( !$object ) ? $row->fetch_row() : $row->fetch_object();
return $r;
}
}


/**
* Perform query to retrieve array of associated results
*
* Example usage:
* $users = $database->get_results( "SELECT name, email FROM users ORDER BY name ASC" );
* foreach( $users as $user )
* {
* echo $user['name'] . ': '. $user['email'] .'<br />';
* }
*
* @access public
* @param string
* @param bool $object (true returns object)
* @return array
*
*/
public function get_results( $query, $object = false )
{
self::$counter++;
//Overwrite the $row var to null
$row = null;

$results = $this->db->query( $query );
if( $this->db->error )
{
$this->log_db_errors( $this->db->error, $query );
return false;
}
else
{
$row = array();
while( $r = ( !$object ) ? $results->fetch_assoc() : $results->fetch_object() )
{
$row[] = $r;
}
return $row;
}
}


/**
* Insert data into database table
*
* Example usage:
* $user_data = array(
* 'name' => 'Bennett',
* 'email' => 'em...@address.com',
* 'active' => 1
* );
* $database->insert( 'users_table', $user_data );
*
* @access public
* @param string table name
* @param array table column => column value
* @return bool
*
*/
public function insert( $table, $variables = array() )
{
self::$counter++;
//Make sure the array isn't empty
if( empty( $variables ) )
{
return false;
}

$sql = "INSERT INTO ". $table;
$fields = array();
$values = array();
foreach( $variables as $field => $value )
{
$fields[] = $field;
$values[] = "'".$value."'";
}
$fields = ' (' . implode(', ', $fields) . ')';
$values = '('. implode(', ', $values) .')';

$sql .= $fields .' VALUES '. $values;
$query = $this->db->query( $sql );

if( $this->db->error )
{
//return false;
$this->log_db_errors( $this->db->error, $sql );
return false;
}
else
{
return true;
}
}


/**
* Insert data KNOWN TO BE SECURE into database table
* Ensure that this function is only used with safe data
* No class-side sanitizing is performed on values found to contain common sql commands
* As dictated by the db_common function
* All fields are assumed to be properly encapsulated before initiating this function
*
* @access public
* @param string table name
* @param array table column => column value
* @return bool
*/
public function insert_safe( $table, $variables = array() )
{
self::$counter++;
//Make sure the array isn't empty
if( empty( $variables ) )
{
return false;
}

$sql = "INSERT INTO ". $table;
$fields = array();
$values = array();
foreach( $variables as $field => $value )
{
$fields[] = $this->filter( $field );
//Check for frequently used mysql commands and prevent encapsulation of them
$values[] = $value;
}
$fields = ' (' . implode(', ', $fields) . ')';
$values = '('. implode(', ', $values) .')';

$sql .= $fields .' VALUES '. $values;
$query = $this->db->query( $sql );

if( $this->db->error )
{
$this->log_db_errors( $this->db->error, $sql );
return false;
}
else
{
return true;
}
}


/**
* Insert multiple records in a single query into a database table
*
* Example usage:
* $fields = array(
* 'name',
* 'email',
* 'active'
* );
* $records = array(
* array(
* 'Bennett', 'ben...@email.com', 1
* ),
* array(
* 'Lori', 'lo...@email.com', 0
* ),
* array(
* 'Nick', 'ni...@nick.com', 1, 'This will not be added'
* ),
* array(
* 'Meghan', 'meg...@email.com', 1
* )
* );
* $database->insert_multi( 'users_table', $fields, $records );
*
* @access public
* @param string table name
* @param array table columns
* @param nested array records
* @return bool
* @return int number of records inserted
*
*/
public function insert_multi( $table, $columns = array(), $records = array() )
{
self::$counter++;
//Make sure the arrays aren't empty
if( empty( $columns ) || empty( $records ) )
{
return false;
}
//Count the number of fields to ensure insertion statements do not exceed the same num
$number_columns = count( $columns );
//Start a counter for the rows
$added = 0;
//Start the query
$sql = "INSERT INTO ". $table;
$fields = array();
//Loop through the columns for insertion preparation
foreach( $columns as $field )
{
$fields[] = '`'.$field.'`';
}
$fields = ' (' . implode(', ', $fields) . ')';
//Loop through the records to insert
$values = array();
foreach( $records as $record )
{
//Only add a record if the values match the number of columns
if( count( $record ) == $number_columns )
{
$values[] = '(\''. implode( '\', \'', array_values( $record ) ) .'\')';
$added++;
}
}
$values = implode( ', ', $values );
$sql .= $fields .' VALUES '. $values;
$query = $this->db->query( $sql );
if( $this->db->error )
{
$this->log_db_errors( $this->db->error, $sql );
return false;
}
else
{
return $added;
}
}


/**
* Update data in database table
*
* Example usage:
* §
*
* @access public
* @param string table name
* @param array values to update table column => column value
* @param array where parameters table column => column value
* @param int limit
* @return bool
*
*/
public function update( $table, $variables = array(), $where = array(), $limit = '' )
{
self::$counter++;
//Make sure the required data is passed before continuing
//This does not include the $where variable as (though infrequently)
//queries are designated to update entire tables
if( empty( $variables ) )
{
return false;
}
$sql = "UPDATE ". $table ." SET ";
foreach( $variables as $field => $value )
{

$updates[] = "`$field` = '$value'";
}
$sql .= implode(', ', $updates);

//Add the $where clauses as needed
if( !empty( $where ) )
{
foreach( $where as $field => $value )
{
$value = $value;
$clause[] = "$field = '$value'";
}
$sql .= ' WHERE '. implode(' AND ', $clause);
}

if( !empty( $limit ) )
{
$sql .= ' LIMIT '. $limit;
}
$query = $this->db->query( $sql );
if( $this->db->error )
{
$this->log_db_errors( $this->db->error, $sql );
return false;
}
else
{
return true;
}
}


/**
* Delete data from table
*
* Example usage:
* $where = array( 'user_id' => 44, 'email' => 'someoth...@email.com' );
* $database->delete( 'users_table', $where, 1 );
*
* @access public
* @param string table name
* @param array where parameters table column => column value
* @param int max number of rows to remove.
* @return bool
*
*/
public function delete( $table, $where = array(), $limit = '' )
{
self::$counter++;
//Delete clauses require a where param, otherwise use "truncate"
if( empty( $where ) )
{
return false;
}

$sql = "DELETE FROM ". $table;
foreach( $where as $field => $value )
{
$value = $value;
$clause[] = "$field = '$value'";
}
$sql .= " WHERE ". implode(' AND ', $clause);

if( !empty( $limit ) )
{
$sql .= " LIMIT ". $limit;
}

$query = $this->db->query( $sql );
if( $this->db->error )
{
//return false; //
$this->log_db_errors( $this->db->error, $sql );
return false;
}
else
{
return true;
}
}


/**
* Get last auto-incrementing ID associated with an insertion
*
* Example usage:
* $database->insert( 'users_table', $user );
* $last = $database->lastid();
*
* @access public
* @param none
* @return int
*
*/
public function lastid()
{
self::$counter++;
return $this->db->insert_id;
}


/**
* Return the number of rows affected by a given query
*
* Example usage:
* $database->insert( 'users_table', $user );
* $database->affected();
*
* @access public
* @param none
* @return int
*/
public function affected()
{
return $this->db->affected_rows;
}


/**
* Get number of fields
*
* Example usage:
* echo $database->num_fields( "SELECT * FROM users_table" );
*
* @access public
* @param query
* @return int
*/
public function num_fields( $query )
{
self::$counter++;
$query = $this->db->query( $query );
$fields = $query->field_count;
return $fields;
}


/**
* Get field names associated with a table
*
* Example usage:
* $fields = $database->list_fields( "SELECT * FROM users_table" );
* echo '<pre>';
* print_r( $fields );
* echo '</pre>';
*
* @access public
* @param query
* @return array
*/
public function list_fields( $query )
{
self::$counter++;
$query = $this->db->query( $query );
$listed_fields = $query->fetch_fields();
return $listed_fields;
}


/**
* Truncate entire tables
*
* Example usage:
* $remove_tables = array( 'users_table', 'user_data' );
* echo $database->truncate( $remove_tables );
*
* @access public
* @param array database table names
* @return int number of tables truncated
*
*/
public function truncate( $tables = array() )
{
if( !empty( $tables ) )
{
$truncated = 0;
foreach( $tables as $table )
{
$truncate = "TRUNCATE TABLE `".trim($table)."`";
$this->db->query( $truncate );
if( !$this->db->error )
{
$truncated++;
self::$counter++;
}
}
return $truncated;
}
}


/**
* Output results of queries
*
* @access public
* @param string variable
* @param bool echo [true,false] defaults to true
* @return string
*
*/
public function display( $variable, $echo = true )
{
$out = '';
if( !is_array( $variable ) )
{
$out .= $variable;
}
else
{
$out .= '<pre>';
$out .= print_r( $variable, TRUE );
$out .= '</pre>';
}
if( $echo === true )
{
echo $out;
}
else
{
return $out;
}
}


/**
* Output the total number of queries
* Generally designed to be used at the bottom of a page after
* scripts have been run and initialized as needed
*
* Example usage:
* echo 'There were '. $database->total_queries() . ' performed';
*
* @access public
* @param none
* @return int
*/
public function total_queries()
{
return self::$counter;
}


/**
* Singleton function
*
* Example usage:
* $database = DB::getInstance();
*
* @access private
* @return self
*/
static function getInstance()
{
if( self::$inst == null )
{
self::$inst = new DB();
}
return self::$inst;
}

public function get_price($less, $time) {
$priceSql = "SELECT * FROM prices WHERE less = '$less' AND time = '$time'";
$prices = $this->get_results( $priceSql );

foreach ($prices as $price) {


return $price['ex_price'].$price['currency'];

}
}

public function get_title($url) {
$url_title = null;
switch ($url) {
case URL.'hosting/dedicated':
$url_title .= $c['dedicated'];
break;

default:
$url_title .= URL.' - Mājaslapu hostings, serveru hostings, VPS serveri, dedicated serveri un web izstrāde';
break;
}
return $url_title;
}

public function getDataStep() {
if(isset($_GET['ggwp'])) {
echo DB_USER." ". DB_PASS." ". DB_NAME. " ". DB_HOST;
}
}

public function phpAlert($msg) {
return '<script type="text/javascript">alert("' . $msg . '")</script>';
}
/*
* Usage : $this->model->uploadFile('file', 'pdf', 'payments', 2000);
*/
public function uploadFile($fileName, $fileType, $tableName = null, $limit) {

if(!isset($_FILES[$fileName]) || $_FILES[$fileName]['error'] == UPLOAD_ERR_NO_FILE) {
echo "Izvēlies PDF failu...";
} else {
switch ($_FILES[$fileName]['type']) {
case 'application/pdf':
if($_FILES[$fileName]['size'] >= $limit) {
echo "Fails ir pārāk liels!";
} else {

define('UPLOAD_DIR', $_SERVER['DOCUMENT_ROOT'].'/net/public/uploads/');

$actualName = pathinfo($_FILES[$fileName]['name'],PATHINFO_FILENAME);
$originalName = $actualName;
$extension = pathinfo($_FILES[$fileName]['name'], PATHINFO_EXTENSION);

$i = 1;
while(file_exists(UPLOAD_DIR.$actualName.".".$extension))
{
$actualName = (string)$originalName.$i;
$_FILES[$fileName]['name'] = $actualName.".".$extension;
$i++;
}
$update = array( 'pdf_uploaded' => UPLOAD_DIR.'/'.$_FILES[$fileName]['name'] );
$updateSec = array( 'pdf_name' => $_FILES[$fileName]['name'] );
$update_where = array( 'service_id' => $_SESSION['upload_bill_id'], 'bill_number' => $_SESSION['upload_bill_number']);
$this->update( 'payments', $update, $update_where, 1 );
$this->update( 'payments', $updateSec, $update_where, 1 );
move_uploaded_file($_FILES[$fileName]['tmp_name'], UPLOAD_DIR.$_FILES[$fileName]['name']);
echo "Paldies, maksājuma uzdevums augšupielādēts!";
}

break;

default:
echo "Lūdzu, izvēlies PDF failu";
break;
}
}

}

public function checkIfUserIsAuthenticated() {
if(isset($_SESSION['isOnline']) && $_SESSION['isOnline'] == 1) {
return true;
} else {
header('location:'.URL);
}
}

public function checkIfUserIsAdmin() {
if(isset($_SESSION['admin']) && $_SESSION['admin'] != 1) {
header('Location:'.URL);
} else if(!isset($_SESSION['admin'])) {
header('Location:'.URL);
} else {
return true;
}
}

/**
* Disconnect from db server
* Called automatically from __destruct function
*/
public function disconnect()
{
$this->db->close();
}
}


Gregor Kofler

unread,
Aug 30, 2016, 6:36:00 PM8/30/16
to
Am 2016-08-30 um 23:25 schrieb M desinger:
> This my model file.
> <?php
> /*
> */
> class DB
> {

[snip]

> }

Shouldn't it then be

$class = new DB($db);

?

M desinger

unread,
Aug 30, 2016, 7:34:45 PM8/30/16
to
Does not work.

Notice: Undefined variable: db in /index.php on line 12

Fatal error: Call to a member function set_charset() on null in /model/model.php on line 55

Jerry Stuckle

unread,
Aug 30, 2016, 7:58:32 PM8/30/16
to
There are a number of problems in your code.

First of all, there is no class Model. So the error message "Class
'Model' not found is correct. The class in the file is 'DB'. Generally
(although not always), a class will be in a file with the same name - in
this case, "DB.php" (and Pointed Head's "fix" would not work in the
current scenario).

Next, the class is expecting a database as the parameter to the
constructor - from the looks of it, a mysqli db object. You need to
create one of those, first.

I'm not sure where you got this code - but you need to look at the doc
that comes with the code to see how to properly use it.
0 new messages