Write a PHP encountered an error: the Object of the class mysqli could not be converted to a string
An object of class mysqli_result cannot be converted to a string
Check the code:
An object of class mysqli_result cannot be converted to a string
Check the code:
function query($sql){
echo $sql;
$query = mysqli_query(self::$con,$sql)or die(mysqli_error(self::$con));
return $query;
}
Mysqli_result is returned by mysqli_query, so the error should be on the return value.
You cannot directly output an object as a string in PHP5 above.
So just change the type of the return value.
function query($sql){
echo $sql;
$query = mysqli_query(self::$con,$sql)or die(mysqli_error(self::$con));
return mysqli_fetch_array($query);
//return $query;
}
Returns as an array with the mysqli_fetch_array() function.
Read More:
- PHP error in Windows: class’ mysqli ‘not found
- PHP use __Sleep() and __wakeup() method serializes the object
- [Solved] PHP Fatal error: Uncaught Error: Class ‘Redis‘ not found in
- Mac PHP Fatal error: Class ‘Memcache’ not found
- laravel The Process class relies on proc_open, which is not available on your PHP installation.
- Using $this when not in object context in (How to Fix)
- [PHP] __autoload function will be called when class_exists does not exist
- Fatal error: Function name must be a string in
- PHP php-config is not installed error in ubuntu 16 [How to Solve]
- [PHP] Array to string conversion error when sending data in post
- PHP: How to get the total number of data in the MySQL table (total number of rows)
- How to Solve PHP Fatal error: Namespace declaration statement has to be the very first statement
- Error during session start; please check your PHP and/or webserver log file and configure your PHP
- PHP: How to parse MHT file into HTML
- [Solved] WordPress Upgrade PHP 5.6 to 7.x Fatal error: Uncaught Error: Call to undefined function mysql_connect()
- [Solved] Type error: Argument 1 passed to Monolog\Utils::getClass() must be an instance of Monolog\object
- [PHP]json_encode Chinese JSON_UNESCAPED_UNICODE returns null in php5.3
- /www/server/php/56/sbin/php-fpm:error while loading shared libraries:libssl.so.1.0. 0:cannot open shared object file:No such file or directory
- [PHP] php8 jit does not support 32-bit systems WARNING: JIT not supported by host architecture
- [Solved] Fatal error: Class ‘think\Container‘ not found & [InvalidArgumentException] Could not find package