Fatal error: calling undefined stdClass method

I get an error

Fatal error: calling the undefined method stdClass :: mysql_con () on .......... /.../includes/script/import.php on line 68.

Line 68 corresponds to:

if(!$ip2c->mysql_con())

I have a statement require_once()at the beginning of my script

What could be the problem?

thanks

+3
source share
5 answers

Dusoft says this could mean:

  • $ip2c the object does not exist

    What does not match is not because you get another error " Fatal error: Call to a member function mysql_con() on a non-object"

He also says this could mean:

  • mysql_con The function is not part of the class you are trying to call.

    , , stdClass.

, quote:

  • , , / , , PHP "stdClass" ( . )

, , :

  • $ip2c , php , stdClass - .

    , .

 $ip2c = null;

 //php casts $ip2c to 'stdClass'
 $ip2c->foo = bah;

 //Fatal error: Call to undefined method stdClass::mysql_con() in...
 $ip2c->mysql_con();

.

+9

, $ip2c , mysql_con , .

+1

, , extension = php_mysql.dll php.ini.

phpinfo();

0

. , :

if ($myObj->property_exists('min')){
    // do something
}

:

PHP : undefined stdClass:: property_exists() myFile.php ###

:

if (property_exists($myObj, 'min')) {
    // do something
}

.

0

, . , , . (, __construct, ), :

$ip2c = new Class;

. :

$this->ip2c = new Class;

$this->ip2c->mysql_con();
0
source

Source: https://habr.com/ru/post/1720115/


All Articles