Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get_magic_quotes_gpc() returns undefined in my code

Tags:

php

I just installed a new version of XAMPP and the site that used to work perfectly now no longer works, I suppose it's a PHP incompatibility, can anyone help me? tnks in adv..

Fatal error: Uncaught Error: Call to undefined function get_magic_quotes_gpc() in D:\xampp\htdocs\index.php:207 Stack trace: #0 {main} thrown in D:\xampp\htdocs\index.php on line 207
    \\ The path to the "application" folder
    if (is_dir($application_folder))
    {
        define('APPPATH', $application_folder.'/');
    }
    else
    {
        if ( ! is_dir(BASEPATH.$application_folder.'/'))
        {
            exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);
        }

        define('APPPATH', BASEPATH.$application_folder.'/');
    }

    if(get_magic_quotes_gpc())
    {
        function stripslashes_gpc(&$value)
        {
            $value = stripslashes($value);
        }
        
        array_walk_recursive($_GET, 'stripslashes_gpc');
        array_walk_recursive($_POST, 'stripslashes_gpc');
        array_walk_recursive($_COOKIE, 'stripslashes_gpc');
        array_walk_recursive($_REQUEST, 'stripslashes_gpc');
    }

thanks @WiatroBosy for your help.

I think I solved the problem because the message has now changed and has diverted the error to another file.. I solved the first problem like this..(I don't know if I did it right)

if(  function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc())

The new error now is:

Fatal error: Cannot declare class CI_Log, because the name is already in use in D:\xampp\htdocs\system\libraries\Log.php on line 27 (line 27) class CI_Log {
like image 689
Dottor Cox Avatar asked Dec 17 '25 13:12

Dottor Cox


2 Answers

This function has been DEPRECATED as of PHP 7.4.0 and REMOVED in 8.0.0.

Hence you should just remove this function call from the code, along with entire condition where it's used.

Read the documentation of get_magic_quotes_gpc()

like image 105
WiatroBosy Avatar answered Dec 19 '25 07:12

WiatroBosy


Add this function to your php file

if (!function_exists('get_magic_quotes_gpc')) {
function get_magic_quotes_gpc()
{
    // Check if magic quotes GPC emulation is needed
    if (version_compare(PHP_VERSION, '5.4.0', '<')) {
        return (bool) ini_get('magic_quotes_gpc');
    } else {
        return false; // Magic quotes GPC is deprecated and not available
    }
}

}

like image 24
Isaac Muturi Avatar answered Dec 19 '25 05:12

Isaac Muturi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!