Kode virker ikke mere
Min kode til mit forum virker ikke optimalt mere efter at have kørt et års tid uden problemer. Jeg har prøvet at løse det, men de løsninger jeg har prøvet virker ikke.Koden ser sådan ud:
<?php
if (empty($rowStart)) { $rowStart = 0; }
if ($id) {
$rs = sql("SELECT thread FROM forums WHERE id = '$id' AND sports_id = '$sport_id'");
if ($row = mysql_fetch_array($rs)) { extract($row); }
$sql = "SELECT thread, count(id) AS tcount, max(id) as maxid FROM forums WHERE thread = '$thread' AND sports_id = '$sport_id' GROUP BY thread ORDER BY thread DESC";
} else {
$rs = sql("SELECT thread FROM forums WHERE sports_id = '$sport_id'");
$numrows = mysql_num_rows($rs);
$sql = "SELECT thread, count(id) AS tcount, max(id) as maxid FROM forums WHERE sports_id = '$sport_id' GROUP BY thread ORDER BY thread DESC LIMIT $rowStart,$showLimits";
}
$rs_threads = sql($sql);
$rec = mysql_fetch_array($rs_threads);
$aryThreadstring=array();
$threads=array();
$max=0;
$min=0;
for ($i = 0; is_array($rec); $i++){
if($rec["thread"]>$max) {
$max=$rec["thread"];
if($min==0) {
$min=$max;
}
} elseif ($rec["thread"]<$min) {
$min=$rec["thread"];
}
$aryThreadstring[$rec["thread"]] = $rec["thread"];
$threads[]=$rec;
$rec = mysql_fetch_array($rs_threads);
}
$threadstring = implode(",",$aryThreadstring);
if ($id) {
$sql1 = "SELECT id AS id, headline AS subject, name AS author, forumsDate AS datestamp, refID AS parent, thread FROM forums WHERE thread = '$thread' AND sports_id = '$sport_id' AND active = 'Y' ORDER BY thread DESC, id ASC";
} else {
$sql1 = "SELECT id AS id, headline AS subject, name AS author, forumsDate AS datestamp, refID AS parent, thread FROM forums WHERE thread<='$max' AND thread>='$min' AND sports_id = '$sport_id' AND active = 'Y' ORDER BY thread DESC, id ASC";
}
$headers=array();
$rs_subLinies = sql($sql1);
$rec = mysql_fetch_array($rs_subLinies);
while(is_array($rec)){
if(!empty($rec["thread"])){
$headers[]=$rec;
}
$rec = mysql_fetch_array($rs_subLinies);
}
$rows=@count($headers);
include ("multi-threads.php");
?>
Ps. sql() er en funktion der ser sådan ud:
function sql($sql) {
$sql_host = "tom";
$sql_user = "tom";
$sql_pass = "tom";
$sql_db = 'tom';
mysql_connect($sql_host,$sql_user,$sql_pass);
mysql_select_db($sql_db);
flush();
return @mysql_query($sql);
mysql_close();
}
Der hvor jeg har fundet ud af hvor fejlen er, er ved linien $rs_subLinies = sql($sql1);
Jeg kan oplyse at den ikke kommer ud med fejlmeddelse og hvis jeg kører sql-sætningen i databasen, får jeg output.
Når den kommer dertil, så stopper resten af scriptet. Jeg kan ikke finde ud af hvorfor, men jeg håber at der er en der kan hjælpe mig med mit problem ?
På forhånd tak.