Sir, I am using these codes
It is showing these two error messages as
// username and password sent from Form
if(empty($myusername) || empty($mypassword))
echo '<script>alert("User name and password must not be empty")</script>';
$query="SELECT name FROM admin WHERE mobile='".$myusername."' and password='".$mypassword. "'";
echo "<script>alert('username, password query is not working well')</script>" ;
echo "<script>alert('username, password query is working well')</script>" ;
$error="Your Login Name or Password is invalid";
( ! ) Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\Phonebook\login.php on line 22
( ! ) Warning: mysql_num_rows() expects parameter 1 to be resource, null given in C:\wamp\www\Phonebook\login.php on line 23
Please help me to locate what I am doing wrong?
It is good practice to escape column name with `
$query="SELECT `name` FROM `admin` WHERE `mobile`='".$myusername."' and `password`='".$mypassword. "'";
Those errors are being generated because the query itself is returning false, therefore $row is becoming NULL.
The query is: "SELECT name FROM admin WHERE mobile='".$myusername."' and password='".$mypassword. "'"
How has your "admin" table been structured in the database? Do you definately have the columns: name, mobile and password?
First of all, this:
And it's best to call mysql_num_rows() to make sure there are results before trying mysql_fetch_array().
But it's not clear why your call to mysql_fetch_array() is failing. You might change it to:
to make sure you don't have a syntax error in your SQL.
$result = mysql_query($query) or die(mysql_error());
I often find it useful to include the query in the debug output, too.
Of course, you don't want that sort of thing in the live site, so you'll want to make a more "graceful" error-handler before you go to production.
$result = mysql_query($query) or die(mysql_error()."\n$query");
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)