-3

I am getting the following error:

What is error in the code?

[27-May-2018 20:37:37 UTC] PHP Deprecated:  Methods with the same name as their class will not be constructors in a future version of PHP; FGMembersite has a deprecated constructor in /home/gurudev/public_html/user/include/fg_membersite.php on line 24
[27-May-2018 20:37:37 UTC] PHP Deprecated:  Methods with the same name as their class will not be constructors in a future version of PHP; FormValidator has a deprecated constructor in /home/gurudev/public_html/user/include/formvalidator.php on line 66
[27-May-2018 20:37:58 UTC] PHP Deprecated:  Methods with the same name as their class will not be constructors in a future version of PHP; FGMembersite has a deprecated constructor in /home/gurudev/public_html/user/include/fg_membersite.php on line 24
[27-May-2018 20:37:58 UTC] PHP Deprecated:  Methods with the same name as their class will not be constructors in a future version of PHP; FormValidator has a deprecated constructor in /home/gurudev/public_html/user/include/formvalidator.php on line 66
[27-May-2018 20:37:58 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function mysql_connect() in /home/gurudev/public_html/user/include/fg_membersite.php:773
Stack trace:
#0 /home/gurudev/public_html/user/include/fg_membersite.php(729): FGMembersite->DBLogin()
#1 /home/gurudev/public_html/user/include/fg_membersite.php(86): FGMembersite->SaveToDatabase(Array)
#2 /home/gurudev/public_html/user/register.php(6): FGMembersite->RegisterUser()
#3 {main}
  thrown in /home/gurudev/public_html/user/include/fg_membersite.php on line 773

Source File is given: http://cache.youthhustle.com/files/source.txt

2 Answers2

1

Please check the version of PHP you're using. mysql_connect() is part of PHP 5.

Quoting from the official site:

Warning This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used.

If you still want to use mysql_connect(), use the corresponding server installation that includes PHP 5.x, eg., XAMPP 5.6.36

You can easily convert all of your PHP 5.x code to PHP 7.x. I've personally used this tool for some of my projects and it works like a charm. But have a backup of your original code somewhere.

justarandomguy
  • 331
  • 4
  • 15
1

[27-May-2018 20:37:37 UTC] PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; FGMembersite has a deprecated constructor in /home/gurudev/public_html/user/include/fg_membersite.php on line 24

It means that the constructor for the class is named in a way that php will no longer support in future version.

class FGMembersite{

    public function FGMemmbersite() : void{
        echo "something";
    }
}

class FGMembersite{

    public function __construct() : void{
        echo "something";
    }
}

new FGMembersite();

both classes would echo "something", the difference is that the constructor method in the first will no longer work in future php versions as being the same name as the class itself; it will have to be __construct()

It's warning you that your code may break down the line.

Glen Elkins
  • 867
  • 8
  • 24