Page 2 of 2

Posted: Fri Sep 07, 2007 3:51 pm
by Poomerio
Nope, it still isn't working. Same errors.

- Poomie

EDIT: Actually, I removed the $dbname from mysql_select_db in do_login.php and that error vanished.

Posted: Fri Sep 07, 2007 3:53 pm
by s.dot
Please read the post again. I edited it.

Posted: Fri Sep 07, 2007 3:55 pm
by Poomerio
Right.
I removed $connect from mysql_query, mysql_close and mysql_select_db.
Now the only error left is:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\apache2triad\htdocs\easybb\login\do_login.php on line 37
That line is as follows:

Code: Select all

if (mysql_num_rows($login_res) == 1)
- Poomie

Posted: Fri Sep 07, 2007 4:00 pm
by s.dot
See what MySQL is telling you with mysql_error()

Code: Select all

$login_res = mysql_query($login_sql) or die(mysql_error());

Posted: Fri Sep 07, 2007 4:10 pm
by Poomerio
Well I think I sorted that issue.

But I have a new one.
I have a setcookie() function, but it's moaning about headers being sent out already.
Warning: Cannot modify header information - headers already sent by (output started at C:\apache2triad\htdocs\easybb\login\includes\header.php:29) in C:\apache2triad\htdocs\easybb\login\do_login.php on line 60
- Poomie

Posted: Fri Sep 07, 2007 4:22 pm
by s.dot
includes/header.php is sending a header on line 29 (either beit a header() call, a white space, or a new line.. it is sending a header)

You should make a practice of calling exit; after your header() calls so the script exits.

Posted: Fri Sep 07, 2007 4:23 pm
by Poomerio
Well I assume that <?php sends out a header, then?
If so, then I can easily modify the code to fix this.

- Poomie

Posted: Fri Sep 07, 2007 4:27 pm
by josa
The error message says it all. You are trying to modify the HTTP headers with setcookie() when the headers has already been sent to the client. Either call setcookie() before you include header.php or check header.php and make sure it's not outputting anything.

/josa

Posted: Fri Sep 07, 2007 4:29 pm
by Poomerio
Yes, header.php does output a string of text.
I read somewhere that using obflush() (is that right?), you can call back the headers.

- Poomie

Posted: Fri Sep 07, 2007 5:12 pm
by josa
Not call back the headers, but postpone output. You buffer the output on the server and then you can control when the buffered data should get sent to the client.

Code: Select all

ob_start(); // start buffering

// write data to the client - this gets stored in the buffer

ob_end_flush(); // flush the buffer and send the headers and contents to the client.
But don't use output buffering if it's not necessary. In this case I think you could solve the problem easily by rearranging a few lines.

/josa