mysql_query stopped working after upgrade to Mysql5 and PHP 5.2

311 Views Asked by At

I can' find solution how to get it working. I upgraded Mysql 4 to Mysql 5 and changed PHP to 5.2, since than i can't activate account and login. What's wrong with this code?

    include_once("conn.php");
    $check_num = $_GET['c'];

    $exists ="SELECT * FROM registry WHERE check = '$check_num'";

    $eresult = mysql_query($exists);

    if (!$eresult) 
    {
        die('<p>Error performing query: ' . mysql_error() . '</p>');
    }
    $row =  mysql_fetch_array($eresult);
    $key = $row['regkey'];
    $name = $row['title'] . ' ' . $row['name'] . ' ' . $row['surname'];
    $user = $row['username'];

    if (mysql_num_rows($eresult) == 1) 
    {
        $selected = mysql_query($eresult);
        $sql = " UPDATE registry 
                        SET check = 'ok'
                        WHERE regkey = $key";

        $result = mysql_query($sql);
        if (mysql_affected_rows() == 1)
            {
                $message = "The account $user has now been activated.";
                echo "<script type=\"text/javascript\">
            alert('The account $user has now been activated.');
            </script>
            <script>document.location.href='../index.php'</script>";

            }
        }
        else
        {
            $message = "There was a problem with your check value, please try copy and pasteing the URL again. ";
        }
    echo $message;
     ?>
3

There are 3 best solutions below

1
On

Please add

error_reporting(E_ALL); 
ini_set("display_errors", 1); 

at the beginning of your code and tell us, what errors do appear.

With this additional information, we might provide more help.

Additional hint: In case you didn't only update PHP/mySQL, but e.g. XAMPP, have a look in the new php.ini file. You probably need to change some settings.

0
On
0
On

Without seeing any error messages I would guess that it is because the mysql_ extension has been deprecated for some time now. In recent versions the mysql extension has been completely removed from the default php install. You should try the mysqli_ or PDO_ extensions instead.