PHP Classes

I've got an error ...

Recommend this page to a friend!

      PHP MySQL to MySQLi  >  PHP MySQL to MySQLi package blog  >  How to Convert MySQL ...  >  All threads  >  I've got an error ...  >  (Un) Subscribe thread alerts  
Subject:I've got an error ...
Summary:Fatal error: Can't use function return value in write context ..
Date:2015-11-23 09:25:41

  1. I've got an error ...   Reply   Report abuse  
brbaso - 2015-11-23 09:25:41
Great work!, but when I included the mysql2i.class.php class in my project I got :

Fatal error: Can't use function return value in write context in C:\xampp182\htdocs\XXXXX\admin\include\mysql2i.class.php on line 59

Line 59 was:


59. if( empty(mysqli_errno($link)) ){
60. return true;
61. }else{
62. return false;
63. }

Obviously problem was in ' empty(mysqli_errno($link) '

A small change fixed things for me:


59. $e = mysqli_errno($link); // added this line
61. if( empty($e) ){ // replaced with $e ...
62. return true;
63. }else{
64. return false;
65. }

Also, replaced in the same way all other occurrences of the 'empty(mysqli_errno($link))' pattern in the mysql2i.class.php class. Now it works and no errors anymore. My PHP: 5.4.31 ...

Hope this make some sense.


  2. Re: I've got an error in PHP version <5,5   Reply   Report abuse  
Dave Smith - 2015-11-23 10:21:46 - In reply to message 1 from brbaso
Thanks for that. This type of statement structure has been allowed somewhere around PHP 5.5 and greater.

It has become the standard coding for me to test bool return values from a function this way, however I don't always remember that there are still plenty of users out there using older, unsupported PHP versions.

This will certainly help anyone else who runs into the same issue.