April 15, 2012

PHP header not working for server bu works perfectly fine on local host

Question by user1334969

this below code works perfectly fine when i try on my local host but when i upload it on to my server it dose not work

$sendquery = "INSERT INTO `message` (`from`, `to`, `subject`, `date`,`message`) VALUES ('".$_SESSION['UID']."', '".$toarray['Uid']."', '$subject','$d', '$message')";
$sendresult = mysql_query($sendquery);

if($sendresult)
{
    header('Location: home.php?action=inbox&success=1');

}
else
{
    header("Location: home.php?action=inbox&success=2");
}

is it problem with my server or the code

Answer by Starx

The localhost and webserver have many differences together. I am guessing the problem to be developed on windows and hosted on linux.

Lowercase all the header string and stop the execution after it

header("location: home.php?action=inbox&success=2");
exit();

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!