PHP Classes

mysqli_error()

Recommend this page to a friend!

      PHP MySQL to MySQLi  >  PHP MySQL to MySQLi package blog  >  Do tomorrow what does...  >  All threads  >  mysqli_error()  >  (Un) Subscribe thread alerts  
Subject:mysqli_error()
Summary:trying to deploy
Messages:9
Author:Adam Fisher
Date:2017-06-26 17:23:50
 

  1. mysqli_error()   Reply   Report abuse  
Picture of Adam Fisher Adam Fisher - 2017-06-26 17:23:50
[Mon Jun 26 17:20:42.166866 2017] [:error] [pid 29942] [client 174.52.214.248:56940] PHP Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in /var/www/html/superveda/webappfiles/includes/mysql2i.class.php on line 126


I have added:

<?
error_reporting(0);
include_once('includes/mysql2i.class.php');

to my index.php, functions.php, and config.php.

What am I missing

  2. Re: mysqli_error()   Reply   Report abuse  
Picture of Adam Fisher Adam Fisher - 2017-06-26 17:48:35 - In reply to message 2 from Adam Fisher
fixed that moving on to next error:

[Mon Jun 26 17:46:01.167949 2017] [:error] [pid 30276] [client 174.52.214.248:57410] PHP Fatal error: Uncaught TypeError: Argument 3 passed to mysqli_fetch_object() must be of the type array, null given in /var/www/html/superveda/webappfiles/includes/mysql2i.class.php:170\nStack trace:\n#0 /var/www/html/superveda/webappfiles/includes/mysql2i.class.php(170): mysqli_fetch_object(Object(mysqli_result), NULL, NULL)\n#1 /var/www/html/superveda/webappfiles/includes/mysql2i.func.php(110): mysql2i::mysql_fetch_object(Object(mysqli_result), NULL, NULL)\n#2 /var/www/html/superveda/webappfiles/includes/functions.php(98): mysql_fetch_object(Object(mysqli_result))\n#3 /var/www/html/superveda/webappfiles/index.php(6): renderHeader('Home')\n#4 {main}\n thrown in /var/www/html/superveda/webappfiles/includes/mysql2i.class.php on line 170

  3. Re: mysqli_error()   Reply   Report abuse  
Picture of Dave Smith Dave Smith - 2017-06-26 19:52:08 - In reply to message 3 from Adam Fisher
Try changing this line it the mysql2i.class.php file...

public static function mysql_fetch_object($result,$class_name=null,$params=null){

to...

public static function mysql_fetch_object($result,$class_name=null,$params=array()){

Dave

  4. Re: mysqli_error()   Reply   Report abuse  
Picture of Adam Fisher Adam Fisher - 2017-06-26 17:24:11
[Mon Jun 26 17:20:42.166866 2017] [:error] [pid 29942] [client 174.52.214.248:56940] PHP Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in /var/www/html/superveda/webappfiles/includes/mysql2i.class.php on line 126


I have added:

<?
error_reporting(0);
include_once('includes/mysql2i.class.php');

to my index.php, functions.php, and config.php.

What am I missing

  5. Re: mysqli_error()   Reply   Report abuse  
Picture of Muhammad Asad Muhammad Asad - 2017-07-28 20:02:15 - In reply to message 2 from Adam Fisher
Hi Adam,

Were you able to fix this? I am also facing the same issue.

  6. Re: mysqli_error()   Reply   Report abuse  
Picture of Dave Smith Dave Smith - 2017-07-29 00:52:37 - In reply to message 5 from Muhammad Asad
Did you apply the change shown above in post number 3?

Dave

  7. Re: mysqli_error()   Reply   Report abuse  
Picture of Luis Miguel Sequeira Luis Miguel Sequeira - 2019-09-24 17:47:45 - In reply to message 6 from Dave Smith
Dave, the latest version of your package already has

public static function mysql_fetch_object($result,$class_name=null,$params=array()){
[...]

Nevertheless, I still get the error

Fatal error: Uncaught TypeError: Argument 3 passed to mysqli_fetch_object() must be of the type array, null given in /[...]/mysql2i.class.php:180

I'm running PHP 7.1.32 (I could do an upgrade to 7.3, if that helps).

I've also changed null to array() in mysql2i.func.php:

function mysql_fetch_object($result,$class_name=null,$params=array()){

return mysql2i::mysql_fetch_object($result,$class_name,$params);

}

This will fix the $params error, but, instead, the problem is now with the $class_name:

Fatal error: Class '' not found in /[...]/mysql2i.class.php on line

Adding $class_name="stdClass" (which is what it's supposed to be by default) results in an even more complex error, stating that this class has the wrong set of parameters or something like that.

One workaround I used was:

public static function mysql_fetch_object($result,$class_name=null,$params=array()){

if ($class_name && $params)
return mysqli_fetch_object($result,$class_name,$params);
elseif ($class_name && !params)
return mysqli_fetch_object($result,$class_name);
else
return mysqli_fetch_object($result);

}

Ugly, I know. But there seems to be a problem with function/method overloading.

I believe that the same happens elsewhere in your code, although, fortunately, I seem now to be getting more warnings, but no fatal errors. Fingers crossed!

(and btw thanks so much for your package!)

  8. Re: mysqli_error()   Reply   Report abuse  
Picture of Mihir Desai Mihir Desai - 2020-01-07 20:48:48 - In reply to message 7 from Luis Miguel Sequeira
Hi Miguel,

Were you able to resolve the "Class '' not found in" error? What were the exact fixes you had to apply? I have tried making the changes in your responsebut am still not able to resolvethe "lass '' not found in" error. Appreciate your help!

  9. Re: mysqli_error()   Reply   Report abuse  
Picture of Mihir Desai Mihir Desai - 2020-01-07 21:52:48 - In reply to message 8 from Mihir Desai
Turns out it was a rookie mistake.....fixed typo in the code fixes I had applied, which has resolved this problem.