Login Script Not Working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Poomerio
Forum Newbie
Posts: 18
Joined: Tue Sep 04, 2007 4:38 am
Location: SE England

Post 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.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Please read the post again. I edited it.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Poomerio
Forum Newbie
Posts: 18
Joined: Tue Sep 04, 2007 4:38 am
Location: SE England

Post 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
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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());
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Poomerio
Forum Newbie
Posts: 18
Joined: Tue Sep 04, 2007 4:38 am
Location: SE England

Post 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
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Poomerio
Forum Newbie
Posts: 18
Joined: Tue Sep 04, 2007 4:38 am
Location: SE England

Post 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
josa
Forum Commoner
Posts: 75
Joined: Mon Jun 24, 2002 4:58 am
Location: Sweden

Post 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
Poomerio
Forum Newbie
Posts: 18
Joined: Tue Sep 04, 2007 4:38 am
Location: SE England

Post 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
josa
Forum Commoner
Posts: 75
Joined: Mon Jun 24, 2002 4:58 am
Location: Sweden

Post 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
Post Reply