Jump to content

Headers (yes, I know)


luthar28

Recommended Posts

Okay, I've read all the rules for Headers...still can't it to execute properly.  At the bottom is my code.  I basically want to check the database, see if the user is already registered, and redirect as appropriate (there is no HTML on my page, no info sent to the browser).  My server doesn't send any error messages.  All I get are white screens. 

 

Now, if I do the headers_sent()...it tells me that it's sent right after the initial connection with the database. 

 

The ONLY way I can get it to redirect, is if I put

<?php

header("location:index.php?msg=3");

?>

at hte very top, but then I can't evalute...which doesn't help me much.

 

Here is the code (obviously, I have more...but it's sending headers in these lines)

 

 

<?php

$connection = mysql_connect("localhost","####","#####");

 

if (!$connection){

echo mysql_errno().": ".mysql_error()."<br/>";

exit;

}

 

if(!mysql_select_db("prixaurora")){

echo("Database not found<br>");

}

Link to comment
Share on other sites

<?php //<-Make sure there is no whitespace before the opening tag, or (HEADERS ALREADY SENT ERROR);
$connection = mysql_connect("localhost","####","#####");

if (!$connection){
echo mysql_errno().": ".mysql_error()."<br/>"; //<-if the connection fails. OUTPUT SENT (HEADERS ALREADY SENT ERROR).
exit;
}

if(!mysql_select_db("prixaurora")){
echo("Database not found<br>"); //<-If the connection fails. OUTPUT sent (HEADERS ALREADY SENT ERROR);
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.