This question already has an answer here:
I am getting the following error :
Warning: mysqli::real_escape_string(): Couldn't fetch mysqli in /var/www/html/example/includes/classes/class.example.php on line 31
I checked whether $this->mysqli is object of class mysqli it returns true but still I am getting this error
<?php
class changetext
{
public $mysqli=null;
function changetext()
{
$this->makeconnection();
}
function makeconnection()
{
global $config;
$this->mysqli=new mysqli( $config['DBHostName'],$config['DBUserName'],$config['DBPassword'],$config['DBName'] );
if($this->mysqli->connect_errno){
echo $this->mysqli->connect_error;
die("could not connect to mysql database");
}
}
function selecttitle($id)
{
if((!is_object($this->mysqli) && !get_class($this->mysqli) == 'mysqli') ||
!($this->mysqli instanceof MySQLi) || !is_a($this->mysqli, 'mysqli') || $this->mysqli->connect_errno)
{
//$this->makeconnection(); //it's not coming here
echo "shivaaa";die();
}
echo "class of $this->mysqli : ".get_class($this->mysqli);
echo "<br>";
echo "instance of $this->mysqli : ".$this->mysqli instanceof MySQLi;
$id = $this->mysqli->real_escape_string($id);
}
}
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire