Activity Stream
48,167 MEMBERS
6672 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1.     
    #1
    Member

    Default [PHP] Notice: Undefined offset: 0 Error.

    Hello, i am new coding. I am working on a auto downloading torrent php script.

    I have been stucked with Undefined offset error. Your help will be very appretiated, thanks.

    Notice: Undefined offset: 0 in /var/www/html/torrent/bgrahul.php on line 351
    Notice: Undefined offset: 0 in /var/www/html/torrent/bgrahul.php on line 363

    Marked those lines to bold and red.

    //***Check whether torrents are complete***
    $check = true;
    while ($check) {
    $c = 0;
    foreach ($id as $value) {
    $result = callTransmission(array("fields" => array("id", "name", "percentDone"), "ids" => array($value)), "torrent-get", $arr[1]);
    preg_match('/"percentDone":[0-9.]+/i', $result[0], $matches);
    $adii = substr($matches[0], 14);
    $anuj = (int) ($adii * 100);
    update_progress($anuj); //CALL FUNCTION
    $anujstatus = "Download In Progress";
    $downcomplete = "Download Finished";
    anujstatus($anujstatus);
    if ($anuj=='100') {
    aditya(100);
    anujstatus($downcomplete);
    echo "<br><br><br><br> Download complete";
    break 2;
    }
    if ($matches[0] == '"percentDone":1.0000')
    $c++;
    }


    if ($c==count($id)) {
    $check = false;
    break 2;
    }
    sleep(5);
    }
    automan Reviewed by automan on . [PHP] Notice: Undefined offset: 0 Error. Hello, i am new coding. I am working on a auto downloading torrent php script. I have been stucked with Undefined offset error. Your help will be very appretiated, thanks. :) Notice: Undefined offset: 0 in /var/www/html/torrent/bgrahul.php on line 351 Notice: Undefined offset: 0 in /var/www/html/torrent/bgrahul.php on line 363 Marked those lines to bold and red. Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    Your regex seems to be broken

    PHP Code: 
    preg_match('/"percentDone":[0-9.]+/i'$result[0], $matches); 
    That doesn't matches

    Output the $result[0]

  4.     
    #3
    Member
    Quote Originally Posted by soft2050 View Post
    Your regex seems to be broken

    PHP Code: 
    preg_match('/"percentDone":[0-9.]+/i'$result[0], $matches); 
    That doesn't matches

    Output the $result[0]
    Yeah, do you have a fix for that ?

  5.     
    #4
    Member
    I don't know what script is this but the regex seems to do what it is intended to do. I think it isn't broken.
    Maybe the problem is with the subject: $result[0] which doesn't contain the needed string?

  6.     
    #5
    Member
    Website's:
    sborg.us
    Check the contents of the torrent file(Open in notepad or any text editor), And also if the torrent is running fine in transmission.

    V3g3ta | Halcyon | Abhi

  7.     
    #6
    Member
    I think you posted that you updated transmission, maybe that changed callTransmission so the preg_match is broken.

    try and print the array to see whats there?
    print_r($result);


    Someone else may fix it, im very basic with coding.

  8.     
    #7
    Member
    Quote Originally Posted by deliteblogger View Post
    I don't know what script is this but the regex seems to do what it is intended to do. I think it isn't broken.
    Maybe the problem is with the subject: $result[0] which doesn't contain the needed string?
    i am more into copy pasting.. dunno coding.

    Quote Originally Posted by Halcyon View Post
    Check the contents of the torrent file(Open in notepad or any text editor), And also if the torrent is running fine in transmission.
    transmission is working fine

  9.     
    #8
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    Execute this:

    PHP Code: 
    //***Check whether torrents are complete***
                    
    $check true;
                    while (
    $check) {
                        
    $c 0;
                        foreach (
    $id as $value) {
                            
    $result callTransmission(array("fields" =>  array("id""name""percentDone"), "ids" => array($value)),  "torrent-get"$arr[1]);
    print_r($result); exit;
                            
    preg_match('/"percentDone":[0-9.]+/i'$result[0], $matches);
                            
    $adii substr($matches[0], 14);
                            
    $anuj = (int) ($adii 100);
                            
    update_progress($anuj); //CALL FUNCTION
                            
    $anujstatus "Download In Progress";
                            
    $downcomplete "Download Finished";
                            
    anujstatus($anujstatus);
                            if (
    $anuj=='100') {
                                
    aditya(100);
                                
    anujstatus($downcomplete);
                                echo 
    "<br><br><br><br> Download complete";
                                break 
    2;
                            }
                            if (
    $matches[0] == '"percentDone":1.0000')
                                
    $c++;
                        }


                        if (
    $c==count($id)) {
                            
    $check false;
                            break 
    2;
                        }
                        
    sleep(5);
                    } 
    and let us know output

  10.     
    #9
    Member
    Quote Originally Posted by Gavo View Post
    I think you posted that you updated transmission, maybe that changed callTransmission so the preg_match is broken.

    try and print the array to see whats there?
    print_r($result);


    Someone else may fix it, im very basic with coding.
    Yes, i roll back to the older version

  11.     
    #10
    Member
    Quote Originally Posted by soft2050 View Post
    Execute this:

    PHP Code: 
    //***Check whether torrents are complete***
                    
    $check true;
                    while (
    $check) {
                        
    $c 0;
                        foreach (
    $id as $value) {
                            
    $result callTransmission(array("fields" =>  array("id""name""percentDone"), "ids" => array($value)),  "torrent-get"$arr[1]);
    print_r($result); exit;
                            
    preg_match('/"percentDone":[0-9.]+/i'$result[0], $matches);
                            
    $adii substr($matches[0], 14);
                            
    $anuj = (int) ($adii 100);
                            
    update_progress($anuj); //CALL FUNCTION
                            
    $anujstatus "Download In Progress";
                            
    $downcomplete "Download Finished";
                            
    anujstatus($anujstatus);
                            if (
    $anuj=='100') {
                                
    aditya(100);
                                
    anujstatus($downcomplete);
                                echo 
    "<br><br><br><br> Download complete";
                                break 
    2;
                            }
                            if (
    $matches[0] == '"percentDone":1.0000')
                                
    $c++;
                        }


                        if (
    $c==count($id)) {
                            
    $check false;
                            break 
    2;
                        }
                        
    sleep(5);
                    } 
    and let us know output

    updated with print_r, soft2050


    Notice: Undefined variable: temp in /var/www/html/donofwarez/xxx/torrents/bgrahul.php on line 338
    Array ( [0] => HTTP/1.1 200 OK Server: Transmission Content-Type: application/json; charset=UTF-8 Date: Wed, 21 Sep 2011 18:29:58 GMT Content-Length: 49 {"arguments":{"torrents":[]},"result":"success"} [1] => )


    //######TORRENT DOWNLOAD START########
    $filename = "/var/www/html/donofwarez/xxx/database/downloads/$title.txt";

    if (file_exists($filename)) {

    $source = "/var/www/html/donofwarez/xxx/database/downloads/$title.txt";
    $downloaded = file_get_contents($source);
    $downloaded = trim($downloaded);
    $startdownload = '';

    if ($downloaded =='Yes') {
    echo "Already downloaded......";
    } else {
    $startdownload = "true";
    }
    } else {
    $startdownload = "true";
    }
    echo $startdownload;
    if ($startdownload =="true") {
    echo "<br><br><br> Starting download: $title";
    $id = array();


    $result = callTransmission(array("filename" => "/var/www/html/donofwarez/xxx/torrents/$torrentfile", "download-dir" => "/home/Downloads/$title/"), "torrent-add", $arr[1]);
    callTransmission(array("seedRatioLimit" => 50, "seedRatioMode" => 1), "torrent-set", $arr[1]);
    /*
    echo "<pre>";
    print_r($result);
    echo "</pre>";
    */
    if (preg_match('/"percentDone":[0-9.]+/i', $result[0], $matches))
    $temp = str_replace('"id":', "", $matches[0]);
    // $temp="hlDr1wqu2ONtM3McVGHoVzfrkp2UgUcGwDt66IuxAe0 LBkru";
    $id[0] = $temp;
    //***OMG! We need the ids as integers! ***
    foreach ($id as $key => $value) {
    $id[$key] = (int) $value;
    }
    //***Check whether torrents are complete***
    $check = true;
    while ($check) {
    $c = 0;
    foreach ($id as $value) {
    $result = callTransmission(array("fields" => array("id", "name", "percentDone"), "ids" => array($value)), "torrent-get", $arr[1]);
    preg_match('/"percentDone":[0-9.]+/i', $result[0], $matches);
    $adii = substr($matches[0], 14);
    $anuj = (int) ($adii * 100);
    update_progress($anuj); //CALL FUNCTION
    $anujstatus = "Download In Progress";
    $downcomplete = "Download Finished";
    anujstatus($anujstatus);
    if ($anuj=='100') {
    aditya(100);
    anujstatus($downcomplete);
    echo "<br><br><br><br> Download complete";
    break 2;
    }
    if ($matches[0] == '"percentDone":1.0000')
    $c++;
    }


    if ($c==count($id)) {
    $check = false;
    break 2;
    }
    sleep(5);
    }

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Did you notice this?
    By Kw3rLn in forum General Discussion
    Replies: 5
    Last Post: 21st Jan 2012, 05:17 PM
  2. Replies: 1
    Last Post: 9th Dec 2011, 10:07 AM
  3. Get Him To Notice You During Sex
    By upnorth in forum General Discussion
    Replies: 14
    Last Post: 15th Apr 2011, 09:50 PM
  4. Adding Domain Error in cPanel (Error from park wrapper:)
    By Ryza in forum General Discussion
    Replies: 0
    Last Post: 20th Feb 2011, 01:57 AM
  5. Replies: 0
    Last Post: 2nd Jan 2010, 08:16 AM

Tags for this Thread

BE SOCIAL