MySQL Extension is Deprecated use MySQLI or PDO instead

Status
Not open for further replies.

Sly

I don't break the rules I bend them.
Oct 28, 2016
246
38
Any ideas/solutions what could be causing this? I have also enlisted "gift.php" for further inspection for this major error.


-------------------------------- PHP CODE BELOW BEWARE -------------------------------
PHP:
<!DOCTYPE html>
<html>
<head>
    <title>Robbo - Daily Gift</title>
    
            <link rel="shortcut icon" href="{url}/app/tpl/skins/{skin}/images/favicon.ico" type="image/vnd.microsoft.icon"/>
            <link rel="stylesheet" href="https://robbo.pw/system/content/theme/brain/gift_styles/common.css" type="text/css">
        <link rel="stylesheet" href="https://robbo.pw/system/content/theme/brain/gift_styles/styles/lightweightmepage.css" type="text/css">
        <link rel="stylesheet" href="https://robbo.pw/system/content/theme/brain/gift_styles/styles/alert.css" type="text/css">
        <link rel="stylesheet" href="https://robbo.pw/system/content/theme/brain/gift_styles/styles/campaigns.css" type="text/css">
        <script type="text/javascript" src="https://robbo.pw/system/content/theme/brain/gift_styles/js/libs2.js"></script>
        <script type="text/javascript" src="https://robbo.pw/system/content/theme/brain/gift_styles/js/visual.js"></script>
        <script type="text/javascript" src="https://robbo.pw/system/content/theme/brain/gift_styles/js/libs.js"></script>
        <script type="text/javascript" src="https://robbo.pw/system/content/theme/brain/gift_styles/js/common.js"></script>
        <script type="text/javascript" src="https://robbo.pw/system/content/theme/brain/gift_styles/js/fullcontent.js"></script>
        <script type="text/javascript" src="https://robbo.pw/system/content/theme/brain/gift_styles/js/lightweightmepage.js"></script>
        
</head>
<body>
<?php
$user = mysql_query("SELECT * FROM `users` WHERE id='".$_SESSION['user']['id']."'");
 while ($u = mysql_fetch_array($user)){
  if ($u['id'] > 0 || $u['id'] != null){
   if(date("Y-m-d") == date("Y-m-d", $u['account_created'])){
       echo "<br><div class=\"rounded-green rounded-done\">You need to be atleast a Robbo member for 1 day!</div>";
   }
   else
   {
    if ($u['online'] == 0){
    if(date("Y-m-d") == $u['LastUsedGift']){
        if ($u['lastmysteryprize'] == null){
            echo '<div class="rounded-red rounded-done">You can only receieve one gift per day!</div>';
        } else {
            echo '<br><div class="rounded-red rounded-done">You can only receive one gift per day!</div>';
            echo '<br><div class="rounded-red rounded-done">You last received a '.$u['LastDailyGift'].'!</div>';
        }
    } else {
        $rare = mysql_query("SELECT * FROM `daily_gift` ORDER BY RAND() LIMIT 1");
        $r = mysql_fetch_assoc($rare);
        if ($r){
            $urRare = $r['rare_id'];
            $urRareName = $r['rare_name'];
            $urRareImg = $r['rare_img'];
            mysql_query("INSERT INTO `items` (`user_id`, `base_item`, `extra_data`) VALUES ('".$_SESSION['user']['id']."', '".$urRare."', '0')");
            mysql_query("UPDATE `users` SET `LastUsedGift` = '".date("Y-m-d", time())."' WHERE `id` = '".$_SESSION['user']['id']."'");
            mysql_query("UPDATE `users` SET `LastDailyGift` = '".$urRareName."' WHERE `id`='".$_SESSION['user']['id']."'");
            echo '<br><div class="rounded-green rounded-done">You have just received a '.$urRareName.'!</div>';
    }}
    } else {
        echo "<br><div class=\"rounded-red rounded-done\">Make sure you're logged out of the client first!</div>";
        echo '<br><div class="rounded-red rounded-done">You last received a '.$u['LastDailyGift'].'!</div>';
    }
  }}}
?>
</body>
</html>
 

Sledmore

Chaturbate Livestreamer
Staff member
FindRetros Moderator
Jul 24, 2010
5,198
3,914
1) Exactly as it says you shouldn't be using anymore. However, in your case that is just a warning - you can use it, but it's advised you use PDO/MySQLi.
2) You're not connected to a database. The script is trying to run a query but it cannot.

You need to connect, like the following:

PHP:
mysql_connect("localhost", "root", "password");
mysql_select_db("database");

Include that at the top of the file, change the password & database and maybe username, or include a configuration file if you have one.
 

Sly

I don't break the rules I bend them.
Oct 28, 2016
246
38
1) Exactly as it says you shouldn't be using anymore. However, in your case that is just a warning - you an use it, but it's advised you use PDO/MySQLi.
2) You're not connected to a database. The script is trying to run a query but it cannot.

You need to connect, like the following:

PHP:
mysql_connect("localhost", "root", "password");
mysql_select_db("database");

Include that at the top of the file, change the password & database and maybe username, or include a configuration file if you have one.

The connection to MySQL has been resolved, but this issue I've enlisted below still persist.
Also as you have stated below that I shouldn't be using MySQL, how so? I mean I'm using MySQL Server 5.7 Via IIS and Navicat /MySQL based. Do I switch to MySQLI, will this change everything if so how do I switch/ where will I start, sorry for my newbie questions but a man has to ask the experienced to learn when the advantage is at hand :)

PHP:
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\inetpub\wwwroot\system\content\theme\brain\pages\gift.php on line 22

Notice: Undefined index: user in C:\inetpub\wwwroot\system\content\theme\brain\pages\gift.php on line 25
 

Sledmore

Chaturbate Livestreamer
Staff member
FindRetros Moderator
Jul 24, 2010
5,198
3,914
I said, and linked MySQL_ linking to the PHP MySQL_ functions, it would be a lot of work to migrate to MySQLi or PDO. You'd have to Google around for guidance, but it isn't a massive concern, yet.

PHP:
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\inetpub\wwwroot\system\content\theme\brain\pages\gift.php on line 22

Notice: Undefined index: user in C:\inetpub\wwwroot\system\content\theme\brain\pages\gift.php on line 25

The top one isn't an error, you have PHP error logging enabled - that's all, you can hide that. The second one also isn't really an error, however in this case it is - this script will not work as $_SESSION['user']['id'] is null, the session is null in it's entirety.

You need to add
PHP:
session_start();
to the top of your file, so sessions are started - then you should be good to go.
 

Sly

I don't break the rules I bend them.
Oct 28, 2016
246
38
I said, and linked MySQL_ linking to the PHP MySQL_ functions, it would be a lot of work to migrate to MySQLi or PDO. You'd have to Google around for guidance, but it isn't a massive concern, yet.



The top one isn't an error, you have PHP error logging enabled - that's all, you can hide that. The second one also isn't really an error, however in this case it is - this script will not work as $_SESSION['user']['id'] is null, the session is null in it's entirety.

You need to add
PHP:
session_start();
to the top of your file, so sessions are started - then you should be good to go.
Sorry to trouble you once more but another error has occurred while adding the session code.
Code:
Notice: A session had already been started - ignoring session_start() in C:\inetpub\wwwroot\system\content\theme\brain\pages\gift.php on line 23

I have used this code instead

Code:
<?php
    if(!isset($_SESSION))
    {
        session_start();
    }
?>

Then we're back to the previous issue, I have not hidden any errors as you have stated if I did then my gift.php should appear white blank? If so then.. what
 
I tried to close all errors by using this code.
Code:
error_reporting = E_ALL & ~E_DEPRECATED
Which lead to another error.
Code:
Parse error: syntax error, unexpected '=' in C:\inetpub\wwwroot\system\content\theme\brain\pages\gift.php on line 23
(This is the only error persisting at the moment)

I have now used another code to turn off error reporting (which turned off all errors)
Code:
error_reporting(0); // Turn off all error reporting
as expected my .gift is now appearing blank/white and I believe isn't responding.
 

Benden

maging ang maganda mamatay
Jun 4, 2010
2,286
1,482
It's appearing blank because there's nothing to display. Did you look at the code?
I'm not sure what you're expecting to appear....
 
  • Like
Reactions: Sly

Sly

I don't break the rules I bend them.
Oct 28, 2016
246
38
It's appearing blank because there's nothing to display. Did you look at the code?
I'm not sure what you're expecting to appear....
@Jaden helped me, it appears that the code ".$_SESSION['user']['id']." was meant to be .User::userData('id').
 
Status
Not open for further replies.

Users who are viewing this thread

Top