Warning: Cannot modify header information - headers already sent by

I have problems with a script which I try to install on a new website.

It says:

Warning: Cannot modify header information - headers already sent by (output started at /home/afghanhoun/domains/afghanhoundpedigrees.com/public_html/php_users/htdocs/users.inc:61) in /home/afghanhoun/domains/afghanhoundpedigrees.com/public_html/php_users/htdocs/processlogin.php on line 70

Usely it would mean there is a “whitespace” in the file. But cannot find any.

The line it refers to (line 61) is:
[php] if (!mysql_connect($USERS_DBHOST, $USERS_DBUSER, $USERS_DBPASS)) {[/php]

Which is part of this function:
[php]
function connect_to_users_db() {

global $USERS_DBHOST,$USERS_DB, $USERS_DBUSER, $USERS_DBPASS;

if (!mysql_connect($USERS_DBHOST, $USERS_DBUSER, $USERS_DBPASS)) {

// couldn't connect

echo "could not connect";

}

if (!mysql_select_db($USERS_DB)) {

// couldn't connect

echo "could not select"; 	

}

}
[/php]

Now I have tried to remove that part of the script to see what happens than.
Than my error becomes:

Warning: access denied for user ‘root’@‘localhost’ (using password no)
Warning: mysql_select_db(): A link to the server could not be established

I have no idea what is wrong? And how to solve it.
Those same scripts work find on another website

The errors are pretty self explanatory. If this is on a web host, you WILL have a password for the database, you aren’t passing one. Don’t use mysql_

The code you posted has nothing to do with headers, that part is coming from other code.

Thanks for you answer, the password is given in and correct on other parts of the database the connection goes right.
But all probably has to do that the sofware/scripts are couple of years old and pretty much outdated.

So far I made the solution simple and contacted the webhost to downgrade the PHP version to 5.3 which will work for this software. And keep it like that till the software is completely written over to MYSQLI. Still working on that, that costs a lot of time :o

headers already sent error is very often because of files like this:

[php]<?php

// some stuff

?>
[/php]

See line #6? That is actually parsed as output, as anything outside of php tags are html (output). Which is one reason it’s recommended to not close php tags at the end of the file.

[hr]

Unrelated: you should really get a rush on that mysqli-conversion (use parameterized queries!). Atm it’s leaking like a sieve

Sponsor our Newsletter | Privacy Policy | Terms of Service