Jump to content

Recommended Posts

im getting this nasty error. is this issue in the database ?

 

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /public_html/download.php on line 20

 

 

 

here is line 20

 

if ($CURUSER['id'] != $owner && $CURUSER['class'] < 3 && mysql_num_rows($points)==0) bark("Access Denied","Currently you do not have access to this torrent, click <a href=buytorrent.php?id=$id>here</a> to get it.");

 

 

 

 

dbconn();
$id = (int)$_GET["id"];



if (!$id)
    bark("ID not found", "You can't download, if you don't tell me what you want!");

$res = mysql_query("SELECT filename, banned, external FROM torrents WHERE id = $id");
$name = mysql_result($res, 0);
$owner = mysql_result($res, 0, 1);

$points = mysql_query("SELECT * FROM `points_torrents` WHERE torrent=$id AND user=$CURUSER[id]");

if ($CURUSER['id'] != $owner && $CURUSER['class'] < 3 && mysql_num_rows($points)==0) bark("Access Denied","Currently you do not have access to this torrent, click <a href=buytorrent.php?id=$id>here</a> to get it.");

$banned = mysql_result($res, 0, 1);
$external = mysql_result($res, 0, 2);
if($banned == 'yes' && $CURUSER['class'] < UC_JMODERATOR) {
        stdhead();
        begin_frame("Error");
        print("<br><BR><center>" . TORRENT_NOT_FOUND . "</center><br><BR>");
        end_frame();
        stdfoot();
        exit();
}


$fn = "$torrent_dir/$id.torrent";

if (!$name)
    bark("File not found", "No file has been found with that ID!");
if (!is_file($fn))
    bark("File not found", "The ID has been found on the Database, but the torrent has gone!<BR><BR>Check Server Paths and CHMODs Are Correct!");
if (!is_readable($fn))
    bark("File not found", "The ID and torrent were found, but the torrent is NOT readable!");
$maniaurl = str_replace("http://","",$SITEURL);
$manianame = str_replace(".torrent","",$name);
$maniaext = ".torrent";
$name = $manianame ."[". $maniaurl ."]". $maniaext;
mysql_query("UPDATE torrents SET hits = hits + 1 WHERE id = $id");

header("Content-Type: application/x-bittorrent");
header("Content-Disposition: attachment; filename=\"$name\"");

if ($external == "yes") {
    $dict = bdec_file($fn, (1024*1024));
    
    if (!is_array($dict['value']['announce-list'])) {
        $dict['value']['announce-list']['type'] = 'list';
        $dict['value']['announce-list']['value'][0]['type'] = 'list';
        $dict['value']['announce-list']['value'][0]['value'][0]['type'] = 'string';
        $dict['value']['announce-list']['value'][0]['value'][0]['value'] = $dict['value']['announce']['value'];
        $dict['value']['announce-list']['value'][0]['value'][0]['strlen'] = strlen($dict['value']['announce']['value']);
        $dict['value']['announce-list']['value'][0]['value'][0] ['string'] = strlen($dict['value']['announce']['value']).":".$dict['value']['announce']['value'];
    }
    $haslocal = false;
    foreach ($dict['value']['announce-list']['value'][0]['value'] as $announce) {
        if (preg_match("/http:\/\/(www\.)?torrentstorage\.com(:80)?\/announce(\.php)?/i", $announce['value']))
            $haslocal = true;
    }

    if (!$haslocal) {
        $n = count($dict['value']['announce-list']['value']);
        $dict['value']['announce-list']['value'][$n]['type'] = 'list';
        $dict['value']['announce-list']['value'][$n]['value'][0]['type'] = 'string';
        $dict['value']['announce-list']['value'][$n]['value'][0]['value'] = "$SITEURL/announce.php";
        $dict['value']['announce-list']['value'][$n]['value'][0]['strlen'] = strlen($dict['value']['announce-list']['value'][$n]['value'][0]['value']);
        $dict['value']['announce-list']['value'][$n]['value'][0]['string'] = strlen($dict['value']['announce-list']['value'][$n]['value'][0]['value']).":".$dict['value']['announce-list']['value'][$n]['value'][0]['value'];
    }

    print(benc($dict));

}else{ // Torrent is local, don't add our announce
    readfile($fn);
}

?>

Link to comment
https://forums.phpfreaks.com/topic/85483-solved-supplied-argument/
Share on other sites

Search these forums for answers to this...it's been discussed a lot.

 

Basically, your query is invalid (some syntax problem probably) and you went ahead and tried to call another mysql funtion (when the first one failed).

 

This is due to poor error checking in code.

 

Proper query steps looks something like this:

 

1. Run query.

2. Check query worked.

3. When query worked, execute next related function, i.e. mysql_fetch_assoc(), mysql_num_rows(), etc.

4. If you called a fetch function, then check that you got data back first before trying to use the data. Don't assume you got data back. The query can work in step 2, but it does not necessarily mean that you got data because your search criteria ("WHERE" clause) might have not matched any data.

Besides what toplay said, look at:

 

$points = mysql_query("SELECT * FROM `points_torrents` WHERE torrent=$id AND user=$CURUSER[id]");

 

The error is telling you that that query is invalid somehow... More than likely it involves invalid columns or values of some sort.

Well, Nhoj gave it away. ha ha :)

 

1. Use this type of syntax:

 

$points = mysql_query("SELECT * FROM `points_torrents` WHERE `torrent` = $id AND `user` = {$CURUSER['id']}");

 

or

 

$points = mysql_query("SELECT * FROM `points_torrents` WHERE `torrent` = $id AND `user`= " . $CURUSER['id']);

 

 

2. User is a reserved word in MySQL so you should change the column name to name it something more meaningful and/or enclose it in backtick marks as I've already illustrated above.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.