Cod: Selectaţi tot
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY torrents.sticky ASC, torrents.id DESC' at line 1Inteleg ca poate codul ar fi fost vechi, dar chiar asa de vechi incat sa nu-mi mearga? Si totusi, eroarea imi zice ca e langa linia 1, dar eu nu am umblat niciodata prin partea aceea.
Cod: Selectaţi tot
$HTMLOUT = '';
$cats = genrelist_albums();
$searchstr = (isset($_GET['search']) ? unesc($_GET['search']) : '');
$cleansearchstr = searchfield($searchstr);
if (empty($cleansearchstr))
unset($cleansearchstr);
if (isset($_GET['sort']) && isset($_GET['type'])) {
$column = '';
$ascdesc = '';
switch ($_GET['sort']) {
case '1': $column = "name";
break;
case '2': $column = "numfiles";
break;
case '3': $column = "comments";
break;
case '4': $column = "added";
break;
case '5': $column = "size";
break;
case '6': $column = "times_completed";
break;
case '7': $column = "seeders";
break;
case '8': $column = "leechers";
break;
case '9': $column = "owner";
break;
default: $column = "id";
break;
}
switch ($_GET['type']) {
case 'asc': $ascdesc = "ASC";
$linkascdesc = "asc";
break;
case 'desc': $ascdesc = "DESC";
$linkascdesc = "desc";
break;
default: $ascdesc = "DESC";
$linkascdesc = "desc";
break;
}
$orderby = "ORDER BY torrents." . $column . " " . $ascdesc;
$pagerlink = "sort=" . intval($_GET['sort']) . "&type=" . $linkascdesc . "&";
} else {
$orderby = "ORDER BY torrents.sticky ASC, torrents.id DESC";
$pagerlink = "";
}
$addparam = "";
$wherea = array();
$wherecatina = array();
if (isset($_GET["incldead"]) && $_GET["incldead"] == 1)
{
$addparam .= "incldead=1&";
if (!isset($CURUSER) || get_user_class() < UC_ADMINISTRATOR)
$wherea[] = "banned != 'yes'";
}
else
{
if (isset($_GET["incldead"]) && $_GET["incldead"] == 2)
{
$addparam .= "incldead=2&";
$wherea[] = "visible = 'no'";
}
else
$wherea[] = "visible = 'yes'";
if ($CURUSER["view_xxx"] != "yes")
$wherea[] = "category != '84'";
}
$category = (isset($_GET["cat"])) ? (int)$_GET["cat"] : false;
$all = isset($_GET["all"]) ? $_GET["all"] : false;
if (!$all)
{
if (!$_GET && $CURUSER["notifs"])
{
$all = True;
foreach ($cats as $cat)
{
$all &= $cat['id'];
if (strpos($CURUSER["notifs"], "[cat" . $cat['id'] . "]") !== False)
{
$wherecatina[] = $cat['id'];
$addparam .= "c{$cat['id']}=1&";
}
}
}
elseif ($category)
{
if (!is_valid_id($category))
stderr("{$lang['browse_error']}", "{$lang['browse_invalid_cat']}");
$wherecatina[] = $category;
$addparam .= "cat=$category&";
}
else
{
$all = True;
foreach ($cats as $cat)
{
$all &= isset($_GET["c{$cat['id']}"]);
if (isset($_GET["c{$cat['id']}"]))
{
$wherecatina[] = $cat['id'];
$addparam .= "c{$cat['id']}=1&";
}
}
}
}
if ($all)
{
$wherecatina = array();
$addparam = "";
}
if (count($wherecatina) > 1)
$wherecatin = implode(",",$wherecatina);
elseif (count($wherecatina) == 1)
$wherea[] = "category = $wherecatina[0]";
$wherebase = $wherea;
if (isset($cleansearchstr))
{
$wherea[] = "MATCH (search_text, ori_descr) AGAINST (" . sqlesc($searchstr) . ")";
//$wherea[] = "0";
$addparam .= "search=" . urlencode($searchstr) . "&";
$orderby = "";
}
$where = implode(" AND ", $wherea);
if (isset($wherecatin))
$where .= ($where ? " AND " : "") . "category IN(" . $wherecatin . ")";
if ($where != "")
$where = "WHERE $where";
if($where == "")
{
$where = "WHERE ";
}
else
{
$where .=" AND ";
}
$res = mysql_query("SELECT COUNT(*) FROM torrents $where category NOT IN (85, 86, 87, 88, 91, 92, 93 ,94, 95, 96) ") or die(mysql_error());
$row = mysql_fetch_array($res,MYSQL_NUM);
$count = $row[0];
if (!$count && isset($cleansearchstr))
{
$wherea = $wherebase;
$orderby = "ORDER BY id DESC";
$searcha = explode(" ", $cleansearchstr);
$sc = 0;
foreach ($searcha as $searchss)
{
if (strlen($searchss) <= 1)
continue;
$sc++;
if ($sc > 5)
break;
$ssa = array();
foreach (array("search_text", "ori_descr") as $sss)
$ssa[] = "$sss LIKE '%" . sqlwildcardesc($searchss) . "%'";
$wherea[] = "(" . implode(" OR ", $ssa) . ")";
}
if ($sc)
{
$where = implode(" AND ", $wherea);
if ($where != "")
$where = "WHERE $where AND";
$q = "SELECT COUNT(*) FROM torrents $where category NOT IN (85, 86, 87, 88, 91, 92, 93 ,94, 95, 96)";
$res = mysql_query($q);
$row = mysql_fetch_array($res);
$count = $row[0];
}
}Ceea ce am adaugat este
Cod: Selectaţi tot
if($where == "")
{
$where = "WHERE ";
}
else
{
$where .=" AND ";
}
$res = mysql_query("SELECT COUNT(*) FROM torrents $where category NOT IN (85, 86, 87, 88, 91, 92, 93 ,94, 95, 96) ") or die(mysql_error());Cod: Selectaţi tot
$where = "WHERE $where AND";
$q = "SELECT COUNT(*) FROM torrents $where category NOT IN (85, 86, 87, 88, 91, 92, 93 ,94, 95, 96)";
$res = mysql_query($q);
$row = mysql_fetch_array($res);Ideea e ca inainte sa adaug bucatile de cod, totul mergea bine. Avand in vedere ca e vorba de mysql cred ca problema ar veni de la mysql count ?