Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
Test site with php 8
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Support

2021-07-27 06:01:17
Hello again guys .
I'm trying PHP 8 on TTV3MySQLi but I have a few errors and I don't know what they are. I will be very happy if you help  :smile

Warning: Undefined array key "id" in /home/xxxx/public_html/backend/functions.php on line 1390
Warning: Undefined array key "search" in /home/xxxx/public_html/backend/functions.php on line 1392
Warning: Undefined array key "name" in /home/xxxx/public_html/backend/functions.php on line 1397
Warning: Undefined array key "search" in /home/xxxx/public_html/backend/functions.php on line 1402
Warning: Undefined array key "id" in /home/xxxx/public_html/backend/functions.php on line 1390
Warning: Undefined array key "search" in /home/xxxx/public_html/backend/functions.php on line 1392
Warning: Undefined array key "name" in /home/xxxx/public_html/backend/functions.php on line 1397
Warning: Undefined array key "search" in /home/xxxx/public_html/backend/functions.php on line 1402
Warning: Undefined array key "action" in /home/xxxx/public_html/admincp.php on line 12
Warning: Undefined array key "do" in /home/xxxx/public_html/admincp.php on line 13


And
Warning: Undefined variable $wait in /home/xxxx/public_html/backend/functions.php on line 1019
Warning: Undefined variable $new in /home/xxxx/public_html/backend/functions.php on line 1100
Warning: Undefined variable $wait in /home/xxxx/public_html/backend/functions.php on line 1194
Warning: Undefined variable $new in /home/xxxx/public_html/backend/functions.php on line 1100
Warning: Undefined variable $wait in /home/xxxx/public_html/backend/functions.php on line 1194
Warning: Undefined variable $new in /home/xxxx/public_html/backend/functions.php on line 1100


And
Warning: Trying to access array offset on value of type null in /home/xxxx/public_html/torrents-details.php on line 738


Thanks in advance
2021-07-27 14:40:03
All pointless errors nothing that causes any breaks - however easy to fix

For undefined vars
$wait ?? '';
Or if numeric
$wait ?? 0;

For undefined keys
If (array_key_exists('action')) {
    $action = ?????
}

For offset need to see line really
2021-07-28 10:21:42
Quote:
M-jay wrote:
For offset need to see line really


Line 738 in torrents-details.php is:
$shortname = CutName(htmlspecialchars($a["name"]), $char1);

And also this line how must be changed I do not understand.
This is (Undefined array key "action")
$action = $_REQUEST["action"];

Thanks M-jay

Edit: Maybe this line:
$action = $_REQUEST["action"];

Replace like this:
if (array_key_exists($_REQUEST,['action'])) {
   $action = ?????
}

:unsure
Last edited by coco on 2021-07-28 11:40:01
2021-07-28 14:57:41
ill try go through each error to give better understanding
using forums.php for example

$action = strip_tags($_REQUEST["action"]);


undefined array error means php expects the $_POST/$_GET array to contain the key action so we can wrap it

if (array_key_exists('action', $_REQUEST)) {
     $action = strip_tags($_REQUEST["action"]);
}


this tells us we only expect action if the $_POST/$_GET array exist

but $action is also a variable so will cause a undefined   variable error so we need a  default value
if (array_key_exists('action', $_REQUEST)) {
     $action = strip_tags($_REQUEST["action"]);
} else {
         // no array so empty string
 $action = '';
}


if a undefined variable is not in array we can quickly add a default value - theme/lang block for example
$stylesheets


we dont know what this is so we add a default value
// for number value
$stylesheets ?? 0;
// for string value
$stylesheets ?? ''


the undefined offset is a little more tricky i can not create this error but it is about a array value
* maybe the array value is not there
* maybe the array is numbered not named
* maybe array is returned in different order

for offset its always good to use var_dump() to see what the array is looking like so for example var_dump($a);

Maybe some else has a bit more knowledge on undefined offset - with me its just trial and error lol
Last edited by M-jay warn on 2021-07-28 15:54:50
2021-07-28 19:42:07
maybe this works for you. I have changed several lines like this, but Im not using php 8, so I cant be 100% sure on it
$shortname = isset(CutName(htmlspecialchars($a["name"]), $char1));

TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
Last edited by MicroMonkey on 2021-07-28 19:44:29
2021-07-29 10:09:53
Thanks for the answers guys, I will try everything
2021-07-29 13:26:20
Happy to help mate

Micromonkey is correct isset() is another option so to just explain a bit for anyone else who finds this topic helpful

The undefined  var
$var = test ?? '', or ?? 0;

This returns 0 (int) or empty string

Array_key_exists and isset returns a bool (true or false)  :thumb
2021-07-30 02:47:45
That says "Update the code, we expect to check these variables now", you want a updated codebase. You want a light-weight solution to all 4 corners, and never seeing any of those warnings. Not errors, warnings.. its training wheels for developers getting into later versions of the PHP intrepeter.

Those warnings should never be noted. But the code is being reworked, and currently as my own edition is too much I think for average user.. await the updates you see posted here!
2021-07-30 18:50:16
It's very difficult for me guys but I try and thank you very much
2021-08-01 22:28:01
Your doing great - keep at it, we are all learning and love what we do on spare time  :grin
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 9
  • Members: 0
  • Guests online: 9
  • Comments: 3
  • Messages: 1,728