Jump to content

[SOLVED] Beta link sharing site, problem with MySQL table searching


exutable

Recommended Posts

Hey I am having trouble searching through my database where category=$category, it tells me that result isn't a valid MySQL argument but it looks legit to me.

 

http://www.daneshea.com/shareabyte

Click on movies and you will find the error on line 71

 

 

I know the code is really unorganized sorry.

 

 

 

<?
session_start();
?>
<link rel="stylesheet" type="text/css" href="/links.css">
<?
include("connect.php");
include("functions.php");

if(!$_REQUEST['offset']) {
        $offset = 0;
        }
else {
        $offset = $_REQUEST['offset'];
     }
$range = 20;
$searchby = $_REQUEST["searchby"];
$order = $_REQUEST["order"];
$name = $_REQUEST['name'];
$link = $_REQUEST['link'];
$category = $_REQUEST['category'];
$categoryarray = array("Movies", "Games", "Porn", "Videos");
$amount = count($categoryarray);


$http = strchr($link, "http://");
$com = strchr($link, ".com");
$net = strchr($link, ".net");
$org = strchr($link, ".org");




if($name) {
if($http and ($com or $net or $org)) {

post($name, $link);

}
elseif(!$http and ($com or $net or $org)) {
        $link = "http://$link";
        post($name, $link);

}
else {
        echo "<p align=\"center\"><font color=\"red\">Invalid Link!</font></p>";
      
}
}
if($searchby) {
        $amount = mysql_result(mysql_query("select COUNT(*) from rapidshare where (name LIKE '%$searchby%' OR link LIKE '%$searchby%')"),0);
        $result = "select name, link, date_format(time, '%c/%e/%Y') as thetime from rapidshare where name LIKE '%$searchby%' order by name $order limit $offset,$range";
     
if($offset >= $range) {
        $prev = $offset-$range;
        $prevlink = "<span class=\"class4\"><a href=\"index.php?searchby=$searchby&order=$order&offset=$prev\">Prev</a></span>";
        }
else {
        $prevlink = "Prev";
        }
if($amount > $range) {
        $next = $offset+$range;
        $nextlink = "<span class=\"class4\"><a href=\"index.php?searchby=$searchby&order=$order&offset=$next\">Next</a></span>";
        }
else {
        $nextlink = "Next";
        }
}

elseif($category) {
$amount = mysql_result(mysql_query("select COUNT(*) from rapidshare where category=$category"),0);
        $result = "select name, link, date_format(time, '%c/%e/%Y') as thetime from rapidshare where category=$category order by name $order limit $offset,$range";
if($offset >= $range) {
        $prev = $offset-$range;
        $prevlink = "<span class=\"class4\"><a href=\"index.php?category=$category&order=$order&offset=$prev\">Prev</a></span>";
        }

else {
        $prevlink = "Prev";
        }

if($amount > $range) {
        $next = $offset+$range;
        $nextlink = "<span class=\"class4\"><a href=\"index.php?category=$category&order=$order&offset=$next\">Next</a></span>";
        }

else {
        $nextlink = "Next";
        }
}

elseif($searchby && $category) {
        
$amount = mysql_result(mysql_query("select COUNT(*) from rapidshare where (name LIKE '%$searchby%' OR link LIKE '%$searchby%') and category = '$category'"),0);
        $result = "select name, link, date_format(time, '%c/%e/%Y') as thetime from rapidshare where name LIKE '%$searchby%' and category = '$category' order by time desc limit $offset,$range";

if($offset >= $range) {
        
$prev = $offset-$range;
        $prevlink = "<span class=\"class4\"><a href=\"index.php?category=$category&searchby=$searchby&order=asc&offset=$prev\">Prev</a></span>";
        }

else {
        $prevlink = "Prev";
        }

if($amount > $offset+$range) {
        
$next = $offset+$range;
        $nextlink = "<span class=\"class4\"><a href=\"index.php?category=$category&searchby=$searchby&order=asc&offset=$next\">Next</a></span>";
        }

else {
        $nextlink = "Next";
        }
}


$nav = "$prevlink | $nextlink";

$query = mysql_query($result);




echo "<body><table cellpadding=2 border=0 align=\"center\" width=\"100\">
<tr><td colspan=\"2\"><span class=\"class2\"><a href=\"post.php\">Post Rapidshare Link</a> | <a href=\"index.php\">Show All</a>"; if($admin == "3") { echo" | <a href=\"/linklogin.php\">Administration</a></span>"; } echo "</td></tr>
<tr><td colspan=\"2\"><h1>Search ShareAbyte</h1></td></tr>
<tr><td colspan=\"2\">Search for links here and they will be displayed below.</td></tr>
<form action=\"index.php\" method=\"post\">
<tr><td>Search:<br><input type=\"text\" name=\"searchby\" style=\"border: 1px solid #000; background-color: #E9EAFF;\"></td><td>Order:<br><select name=\"order\" style=\"border: 1px solid #000; background-color: #E9EAFF;\"><option value=\"asc\">Ascending [A-Z]</option><option value=\"desc\">Descending [Z-A]</option></select></td></tr>
<tr><td colspan=\"2\"><input type=\"submit\" value=\"Search\"></td></tr>
<tr><td colspan=\"2\"><hr></td></tr>
</form>";

if($amount == 0) {
        echo "<tr><td align=\"center\">No result from your search.</td></tr>";
        die();
        }
if($category || $searchby) {
$i = 0;
print_r($query);
     while($row = mysql_fetch_array($query)) {
     $i++; // same thing as you had $i++ is the exact equiv of $i = $i+1;
     extract($row);
           echo "<td><span class=\"class4\"><a href=\"$link\" target=\"_blank\">$name</a></span></td>";
     if($i % 2 == 0) {echo "</tr><tr>"; }
}
}

else {
$a = count($categoryarray);
for ($i = 0; $i<$a; $i++) {

echo "<td><span class=\"class4\"><a href=\"index.php?category=$categoryarray[$i]\" target=\"_blank\">$categoryarray[$i]</a></span></td>";
     if($i % 2 == 0) {echo "</tr><tr>"; }
}
die();
}

echo "<br><tr><td colspan=\"2\"><hr></td></tr>";
echo "<tr><td colspan=\"2\">$nav</td></tr>";
echo "<tr><td colspan=\"2\"><hr></td></tr></table></body>";

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.