Problem: Cannot modify header information ....
Posted: Fri Sep 17, 2004 6:06 am
Hi there again,
i have to redirect the visitor to a specific url, but i get following error:
Can somebody help me?
My code looks like this:
i have to redirect the visitor to a specific url, but i get following error:
I tried with ob_start & ob_end_flush, but nothing worked.Warning: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/bevibed.be/httpdocs/e107/e107_handlers/vote.php:46) in /home/httpd/vhosts/bevibed.be/httpdocs/e107/e107_handlers/vote.php on line 57
Can somebody help me?
My code looks like this:
Code: Select all
<?php
require_once('../../Connections/e107.php');
$userid_voter = $HTTP_POST_VARS['user_voter'];
$id_artdj = $HTTP_POST_VARS['id_artdj'];
$points = $HTTP_POST_VARS['points'];
$url = $HTTP_POST_VARS['url'];
$type = $HTTP_POST_VARS['type'];
//Indien type artiest is********************************************************
if ($type == "artist"){
mysql_select_db($database_e107, $e107);
$query_Recordset1 = sprintf("SELECT * FROM votes WHERE userid = '$userid_voter' AND type_id = '$id_artdj'");
$Recordset1 = mysql_query($query_Recordset1, $e107) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$query_Recordset2 = sprintf("SELECT * FROM bands WHERE band_id = $id_artdj");
$Recordset2 = mysql_query($query_Recordset2, $e107) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totaal_voor = $row_Recordset2['vote_totaal'];
$aantal_voor = $row_Recordset2['vote_aantal'];
$totaal_na = $totaal_voor + $points;
$aantal_na = $aantal_voor + 1;
$gemiddelde = $totaal_na / $aantal_na;
$gemiddelde = (int)$gemiddelde;
if ($totalRows_Recordset1 == "0"){
$insertSQL = sprintf("INSERT INTO votes (userid, vote_type, type_id) VALUES ('$userid_voter', '$type', '$id_artdj')");
$Result1 = mysql_query($insertSQL, $e107) or die(mysql_error());
$updateSQL = ("UPDATE bands SET vote_totaal ='$totaal_na', vote_aantal = '$aantal_na', vote_gemiddelde = '$gemiddelde' WHERE band_id='$id_artdj'");
$Result2 = mysql_query($updateSQL, $e107) or die(mysql_error());?>
<script>alert("Thanx for your vote!")</script> <?
}else{?>
<script>alert("You already voted on this item!")</script>
<? }}
//Indien type dj is********************************************************
if ($type == "dj"){}
//ga naar reffering url*****************************************************
header(sprintf("Location: ".$url.""));
?>