WordPress site not working on PHP 7.4 or above

If you are searching this then likely the PHP (and MySQL version) of your hosting got updated but your WordPress is still running a very old version say like 4.x or you need to get your very old codes running.

The good part is the site can be made up very easily and in a short time. The beauty of PHP (python, java, .Net also) is backward compatibility is very good so in most cases very little code changes are required.

  1. First check if the code still has “mysql_” instead of “mysqli_“. If that is the case – change all “mysql_” to “mysqli_“.
  2. Another change required in this context is mysqli_select_db it now takes two parameters – mysqli_select_db(connection, name)
    And mysqli_query also needs the mysql connection – mysqli_query(connection, query, resultmode)
  3. Next check your error log for errors.
    • One of the most common ones are variable errors like  Illegal string offset ‘output_key’ in /path/to/file
      This can be solved by changing
      $items[$k]->$args[‘output_key’]
      to

      $items[$k]->{$args[‘output_key’]}
    • Another common error is Illegal string offset ‘user_login’.  This error causes the admin to not open. This can be solved by adding the following in user.php just before $user
if(isset($_POST)){ 
$credentials = array( 
   'user_login' => isset($_POST['log']) ? $_POST['log'] : '',
    'user_password' => isset($_POST['pwd']) ? $_POST['pwd'] :'', 
  ); 
}

 

Leave a comment