Why am I getting a warning in my browser do to a PHP code?

  • Thread starter Thread starter Mr. Confused
  • Start date Start date
M

Mr. Confused

Guest
This is the warning:
"Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\Mamdouh_webpage\insert_record.php:1) in C:\wamp\www\Mamdouh_webpage\insert_record.php on line 51"

I should mention that this code bellow was generated by Dreamweaver CS3. Basically when I try to insert a record in my database it will add it, but it doesn't execute the following command which is to go to a specific webpage. Here is the code where I used and more specifically is the line where it says "header(sprintf("Location: %s", $insertGoTo));}"

Any help will be much much appreciated.

$insertGoTo = "/Mamdouh_webpage/index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
Do you mean I should delete whatever is in the <head> ... </head> tag in the index.php??? It doesn't make sense to me because in there is teh information about the title and the color of the page.
Can you be more specific please.
I have solved the problem. Thank you guys for your answers but it was not even close to what I had to do to make it work.
The only thing I have done is replaced the "virtual" command (usually on the top of the code in line 1) with "REQUIRE_ONCE".
Note: you have to do the same for both pages involved otherwise it will not work.
Well done to me :p and thank you guys for your effort :D
 
index.php already has a header. You need to remove it from that file or remove it from the above code. Can't have two.
 
Back
Top