Unstoppable Domains

Whats wrong with this?

Spacemail by SpaceshipSpacemail by Spaceship
Watch

Barrucadu

Established Member
Impact
64
PHP:
<?php

include './Includes/DBconnect.php';

mysql_connect($DBhostname,$DBusername,$DBpassword);
mysql_select_db($DBname);
$result = mysql_query('select from '.$DBusers.' where uname="'.$_POST['usrnm'].'" and pword="'.$_POST['pwcd'].'" limit 1');
mysql_close();

$num = mysql_num_rows($result);

if($num == 1){
	session_start();
	$_SESSION['usrnm'] == $_POST['usrnm'];
	$_SESSION['pwcd'] == $_POST['pwcd'];
	header("Location: http://www.yarrt.com/members/index.php");
}else{
	header("Location: http://www.yarrt.com/badlogin.htm");
}
?>

returns the error:

Code:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in e:\domains\y\yarrt.com\user\htdocs\login.php on line 7

Warning: Cannot modify header information - headers already sent by (output started at e:\domains\y\yarrt.com\user\htdocs\login.php:7) in e:\domains\y\yarrt.com\user\htdocs\login.php on line 16
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
The two errors are connected. Basically your sql is failing to return results, it's writing the error to the page then your trying to write the header to redirect it which is failing as you've already written content to the page (the error message). Try echoing the sql statement then running it directly in phpMyAdmin and looking at the results.

Lux
 
0
•••
yay! its working now! it was the stupidest mistake:

PHP:
select from members_1 where uname="Mikor" and pword="1000" limit 1

should have been

PHP:
select * from members_1 where uname="Mikor" and pword="1000" limit 1

missed out a *
 
0
•••
Glad you fixed it! You should also try and avoid using * as it adds needless overhead. If you know which fields you want (which you should do) you should specify them instead.

Lux
 
0
•••
its only got 2 fields and I need them both so I may as well leave the *

hmm... still dosnt work... it acts as if $num == 0 and redircts to badlogin.htm even when its a good login...

fixed now
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back