Error in response to my header function??

I have my included php page which is coded to re-direct a user if they go on it. My code:
[php]

<?php header("Location: update.php"); session_start(); try { $conn = new PDO("mysql:dbname=db440754197;host=*******", "********", "******" ); $sql = $conn->prepare("SELECT FirstName, LastName, Email, About FROM Users WHERE Email = ? "); $sql->execute(array($_SESSION["email"])); $sql->execute(); $result = $sql -> fetch(); $conn = null; } catch(PDOException $e) { echo $e->getMessage(); $conn = null; } ?>

[/php]

Now when i load the page, that includes this file, it says this at the top: “Warning: Cannot modify header information - headers already sent by (output started at /homepages/22/d440580748/htdocs/update.php:160) in /homepages/22/d440580748/htdocs/updatepdo2.php on line 2”

What am I doing wrong in my code? it seems to be the header function as the problem error points to it on line 2

Is this all the code? What is the purpose of having any code below a header redirect? I feel we’re missing something here.

Well i reasearched and it said that one of the causes is outputting anything before header functions and to do that at the top of the page. so thats why i put the header at the top. and this header is used to evict any
people trying to explore this page. this is one of my queries and is in my server for include and require functions only. not meant to be explored. and when i execute the above code, it gives me that error. what can be wrong?

Is this a pasting error or do you have a blank line above your <?php tag?

[php]

<?php [/php] If there is a blank line there, that is considered output and would cause the error.

No thats not really in my code i made sure there are no white spaces. But that code i showed you is included in update.php. Is this a PHP error? thanks

If you have any output before the include it would cause the same error. You would have to post all code above the include.

I still don’t understand the logic behind a header redirect inside an include.

Sponsor our Newsletter | Privacy Policy | Terms of Service