Jeg får en underig fejl i en kode der hidtil har virket perfekt. Er der nogen der ud fra filerne herunder, kan udlede hvad og hvor fejlen er, samt rette den for mig ?!?
Fejlen:
Warning: Cannot modify header information - headers already sent by (output started at /usr/home/web/web3117/mayday/include/boot.php:55) in /usr/home/web/web3117/mayday/golink.php on line 23
golink.php
<?php
require('include/boot.php');
if (isset($id) && $id > 0) {
$now = date("Y-m-d H:i:s");
$expire = date("Y-m-d H:i:s", time()+3600);
squery("delete from link_sessions where expire < '$now'");
$getsession = query("select expire from link_sessions ".
"where ip = '$REMOTE_ADDR' and link_id = $id and expire > '$now'");
if (sizeof($getsession) == 0) {
// sets timestamp and updates
squery("update links set hits = hits+1 where id = $id");
squery("insert into link_sessions(ip,link_id,expire) ".
"values('$REMOTE_ADDR',$id,'$expire')");
} else {
// ok, no stamp needed
}
$result = query("select distinct url, id from links where id = $id");
$url = $result[0]->url;
header("Location: $url");
exit;
}
?>
boot.php
<?php
$DB_HOST="--host--";
$DB_USER="--user--";
$DB_PASS="--kode--";
$DB_DATABASE="--user--";
if ($BOOT_PHP != 1) {
function query($string) {
global $DB_CONNECTION;
global $DB_DATABASE;
global $DB_USER;
global $DB_PASS;
global $DB_HOST;
if (!$DB_CONNECTION)
$DB_CONNECTION=mysql_connect($DB_HOST,$DB_USER,$DB_PASS);
$sqlresult=mysql_db_query($DB_DATABASE,$string,$DB_CONNECTION);
if (!$sqlresult) {
return array();
}
while ($row=mysql_fetch_object($sqlresult)) {
$result[]=$row;
}
return $result;
}
function squery($string) {
global $DB_CONNECTION;
global $DB_DATABASE;
global $DB_USER;
global $DB_PASS;
global $DB_HOST;
if (!$DB_CONNECTION)
$DB_CONNECTION=mysql_pconnect($DB_HOST,$DB_USER,$DB_PASS);
$sqlresult=mysql_db_query($DB_DATABASE,$string,$DB_CONNECTION);
}
function mappath() {
/* Credits to Beast for helping me with this one */
global $HTTP_HOST;
global $PHP_SELF;
return "http://" . $HTTP_HOST. dirname($PHP_SELF)."/";
}
$BOOT_PHP = 1;
}
?>
functions.php
<?php
function stars($count) {
if ($count > 0) {
return "[".str_repeat("+",$count).str_repeat("-",10-$count)."]";
} else {
return "Afventer...";
}
}
function line($width=380) {
$temp = "<table cellpadding=0 cellspacing=2 border=0 width=$width height=1>".
"<tr><td bgcolor=#0000cf height=1 width=$width>".
"<img src=\\"/rate/cleardot.gif\\" alt=\\"----------------------\\" width=1 height=1></td></tr></table>\\n";
return $temp;
}
function page_start() {
echo "<center><p><b>$title</b></p>\\n";
}
function page_end() {
echo "</center>\\n";
}
?>
links.php (selve systemet)
<?php
include('include/functions.php');
include($DOCUMENT_ROOT.'/includes/adminip.php');
$thisfile = $PHP_SELF;
// linkstrenge til de tre funktioner.
$linkshowtop = "[ <a class='mayday' href=\\"$thisfile\\">Top links</a> ] ";
$linkshowall = "[ <a class='mayday' href=\\"$thisfile?show=all\\">Vis alle</a> ] ";
if ($REMOTE_ADDR == $ADMINIP) {
$linkadd = "[ <a class='mayday' href=\\"$thisfile?addurl=yes\\">Tilføj webside / URL</a> ] ";
}
if (strtolower($show) == "all") {
$where = "";
} else {
$where = " having point >= 0";
}
$count = query("select sum(hits) as cnt from links");
$hitcount = $count[0]->cnt;
$result = query("select id,title,date,rating,hits,url,(hits*rating-(to_days(curdate())-to_days(date))) as point ".
"from links$where order by top desc, point DESC");
page_start("");
echo $linkshowtop;
echo $linkshowall;
echo $linkadd;
if (!isset($addurl)) {
echo "<table width='800' border=0 cellpadding=2 cellspacing=0>\\n";
for ($i=0;$i<sizeof($result);$i++) {
if ($result[$i]->point >= 0) {
$point = $result[$i]->point;
} else {
$point = "-";
}
echo "<tr><td><p title='".$result[$i]->url."'>".
"<a href='/mayday/golink.php?id=".$result[$i]->id."' target='_blank'>".
stripslashes($result[$i]->title)."</a><a href='".$result[$i]->url."'>".
" </a></td>".
"<td><img src=\\"/mayday/rate/".$result[$i]->rating.".gif\\" ".
"alt='".stars($result[$i]->rating)."' width='33' height='9'></td>".
"<td align=\\"right\\">".$result[$i]->hits."</td>";
echo "<td align=\\"right\\">$point</td>";
echo "</tr>\\n";
}
echo "</table>";
} else {
?>
<form action='/mayday/addlink.php' method='post' target='_blank'>
<table width='380' border='0' align='center'>
<tr>
<td>Websidens navn :
<input type='text' name='title' value='' size='30' id='t350'></td>
</tr>
<tr>
<td>URL :
<input type='text' name='url' value='http://' size='30' id='t350'></td>
</tr>
<tr>
<td align='center'><input type='submit' value='Tilføj link' id='submit' name="submit"></td>
</tr>
<tr>
<td align='right'><b>NB!</b> Din IP logges ved "Tilføj link"</td>
</tr>
</table>
</form>
<?}
echo "Total hits : $hitcount\\n";
echo mysql_error();
page_end();
?>
Systemet har virket upåklageligt indtil det seneste server skift..
Systemet kan ses i aktion her
http://anakin.dk/mayday/ og fejlen opstår når der klikkes på linkene..
Med venlig Hilsen Frank
http://anakin.dkJeg giver ikke point for opgavens størrelse, men for hjælpen der ydes..
[Redigeret d. 18/08-04 22:42:38 af Anakin]