karlarneg@gmail.com wrote:
Quote:
Hello.
I am using Xampp on Windows Vista.
PHP 5.2.6
MySql 5.0.51b
>
This is my login code in PHP:
>
if(isset($_POST['login'])){
>
// Connect and select database
include ('connect.inc');
>
$sql = "SELECT * FROM users";
$sql .= "WHERE username ='" . $_POST['username'] . "' ";
$sql .= "AND password='" . $_POST['password'] . "' ";
$results = mysql_query($sql, $dblink);
if(mysql_num_rows($results) != 0){
echo "OK!";
} else {
echo "ERROR";
}
}
>
But this script generate and error:
>
Warning: mysql_num_rows(): supplied argument is not a valid MySQL
result resource in D:\xampp\htdocs\index.php on line 42
ERROR
>
How can I fix this?
Users on my locale server have to login to see my pages. Their
username and password are stored in the database. Is it another way to
write a login script that check the user name and password?
>
Thanks.
>
Karl
>
This question has been asked many times in this newsgroup, as a quick
search would have told you. Figure out what's wrong with your SQL
statement and fix it.
And next time try checking the results of function calls to see if the
calls worked or not, rather than just assuming they did.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================