php - Cannot modify header information -


possible duplicate:
headers sent php

i getting following error following code, , not entirely sure why. if tell me how fix it, great. in advanced.

warning: cannot modify header information - headers sent (output started at...) on line 45.

<?php       // initialization     $conn = mysql_connect(db_host,db_user,db_password);     mysql_select_db(db_name, $conn);      // error checking     if(!$conn) {         die('could not connect ' . mysql_error());     }      // localize variables     $ref  = isset($_get['ref']) ? $_get['ref'] : "";      // protect against sql injections     // insert score     $retval = mysql_query("insert $table(             site         ) values (             '$ref'         )",$conn);      if($retval) {         echo "successfull";     } else {         echo "unsuccessfull " . mysql_error();     }      mysql_close($conn); ?> <?php $url = $_get['url'];     $loc = 'location: '. $url;     header($loc); exit; ?> 

take out echo calls, can't send information browser before headers.

you can try still show if error happens:

if(!$retval) {     echo "unsuccessfull " . mysql_error(); } 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -