-3

I'm getting this error on my gambling site, it's on the progressbar the error occurs.

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\update.php on line 14

update.php:

<?php if(session_id() == '') { session_start(); } ?>
<?php
try {
            $apikey = "C897813F4999AF1EDA50AEECFD9ECCFE";
                $servername = "127.0.0.1";
                $username = "root";
                $password = "admin123";
                $dbname = "Skingamble";

    $conn = new mysqli($servername, $username, $password, $dbname);
    $result = $conn->query("SELECT * FROM `keys`");
    $row = $result->fetch_assoc();
    $result2 = $conn->query("SELECT * FROM `current`");
    $count = mysql_fetch_object($result2);
    echo $count;
    echo 'Deposited keys: ' . $count . " / " . $row["max"];
    if($count=="0" || $row["max"]=="0")
    {
        echo "<script>progress(0)</script>";
    }
    else
    {
        echo "<script>progress(". $count . "/(" .$row["max"] ."/ 100))</script>";
    }

    if($count>=$row["max"])
    {
        $result = $conn->query("SELECT * FROM current ORDER BY RAND() LIMIT 1");
        $row = $result->fetch_assoc();
        $winner = $row["steamid"];
        $result2 = $conn->query("SELECT * FROM steamids WHERE steamid='" . $winner . "' LIMIT 1");
        $roww = $result2->fetch_assoc();
        $token = $roww["tradetoken"];
        $conn->query("INSERT INTO `actions` (`token`, `steamid`) VALUES ('" . $token . "', '" . $winner . "');");
        $conn->query("INSERT INTO `items` (`user`, `action`) VALUES ('" . $winner . "','win');");
        $conn->query("INSERT INTO `log` (`text`, `id`,`type`) VALUES ('<b>WINNER!</b> " . $row["name"] . " won this round!','', 'win');");
        $conn->query("TRUNCATE current;");

    }

    $conn->close();
} catch (Exception $e) {

}

?>
Rizier123
  • 58,877
  • 16
  • 101
  • 156

1 Answers1

0

You are using mysqli for your queries...

Then, mysql_fetch_object does not work correctly because you are passing to it stuff that is not mysql but is mysqli.

Replace

mysql_fetch_object();

With

mysqli_fetch_object();

You can use OR mysql OR mysqli and once you have choosed you'll have to use it during all code