If you like DNray Forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...

 

Error in setting up VDS hosting

Started by therealaleech, Mar 02, 2023, 03:45 AM

Previous topic - Next topic

therealaleechTopic starter

Greetings everyone. I have recently made a switch from virtual hosting to a VPS hosting platform, and unfortunately, I encountered an error along the way.

The specific error message goes as follows:

mod_fcgid: stderr: PHP Fatal error: Can't use method return value in write context in /var/www/www-root/data/www/reallot.kz/application/models/admin_model.php on line 124

Upon analyzing the situation, I believe that the issue lies within this section of code:

empty($cell->getCalculatedValue())

It appears that an empty argument can only be passed a variable.

Interestingly, everything was functioning flawlessly on the virtual hosting platform. Therefore, I am left wondering what could possibly be the cause for this sudden problem to arise.
  •  


ichnolite

I highly recommend making a habit of consulting the official dоcumentation more frequently before seeking answers to your questions. PHP offers a beginner-friendly environment as it not only provides descriptions but also a plethora of diverse examples.

For your particular situation, it seems that the issue stems from migrating the script to a lower version of PHP.

To gain further understanding and insights, I suggest referring to the following link:
https://www.php.net/manual/en/function.empty.php
  •  

matrice

Consider using only $cell->getCalculatedValue(). The concept of !empty is essentially a double negation.

It's worth noting that by removing the !empty part, you simplify the code and avoid potential confusion caused by the double negation. Sometimes, simplicity is key when it comes to writing clean and maintainable code.
  •  

Rickweqw2bjf

The error message you encountered indicates that there's a problem with the way the return value from the method is being used. Specifically, in PHP, the empty() function expects a variable but the way you are using it with a method call might not be compatible with your current PHP version on the VPS.

On some older versions of PHP, it's possible to directly use method calls inside empty(). However, in more recent versions, it can throw a fatal error because the return value of a method cannot be treated as a variable for certain functions. This is likely why everything was working correctly on your virtual hosting platform but is causing issues now.

To fix this, you can first assign the return value of getCalculatedValue() to a variable and then use that variable with empty(). Here's how you can revise your code:

$value = $cell->getCalculatedValue();
if (empty($value)) {
    // Your code for handling empty values
}

By doing this, you're ensuring that you are passing a variable to empty(), thus adhering to the requirements of any recent PHP version.

It's also worth checking what PHP version is currently running on your VPS compared to your previous hosting. There might be additional differences that could affect your code. Also, verifying any other configurations in php.ini that might differ could help in identifying other potential issues.

Make sure your testing or development environment closely mirrors your production environment to avoid such discrepancies in the future. Always keeping the version control and compatibility in check will save you a lot of headaches down the line.
  •  


If you like DNray forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...