0

Pretty new at php and working on my class project.

I get this error code on my action page for my log in page plus, it does not redirect when the result is wrong. I still get into the members' area.

Code below. Thanks

"mysql_num_rows(): supplied argument is not a valid MySQL result resource"

<?php
$conn=mysql_connect("localhost","root","");
if ($conn) {
print "Connection ok. <br>";
}
$select=mysql_select_db("litto",$conn);
print "Database selected.<br>";
$sql="SELECT * FROM users WHERE username='$_POST[username] AND password='$_POST[password]'";
$results=mysql_query($sql);
if (mysql_num_rows(results)> 0) {
print "Welcome to the system";
}
else{
print "check username and password";
}
admin.php;
mysql_close($conn);
?>

4
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by Brianbc
0

Typo, in mysql query,
single quote missing (') after $_POST[username]

$sql="SELECT * FROM users WHERE username='$_POST[username] AND password='$_POST[password]'";

Edited by kasim.badami: n/a

0

Thanks for the feedback. Got it working.

Today I am going to present my project. Keeping my fingers crossed for my Diploma in Web & Graphic Design.

0

Thanks kasim.badami. I had also been strugling with the same problem the entire day till I realised this(') was missing!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.