Mysql_fetch_array problem

Sir, I am using these codes

[php]<?php
if(isset($_POST[‘login’])){
require_once(“connect.php”);
session_start();
// username and password sent from Form
$myusername=addslashes($_POST[‘username’]);
$mypassword=addslashes($_POST[‘password’]);

if(empty($myusername) || empty($mypassword))
{
echo ‘’;
}else{
$query=“SELECT name FROM admin WHERE mobile=’”.$myusername."’ and password=’".$mypassword. “’”;

$result=mysql_query($query);
if(!$result)
{
echo “” ;
}else{
echo “” ;
}
$row=mysql_fetch_array($result);
$count=mysql_num_rows($row);

if($count==1)
{
session_register(“myusername”);
$_SESSION[‘myusername’]=$myusername;
header(“location: welcome.php”);
}else {
$error=“Your Login Name or Password is invalid”;
}
}
}
?>
[/php]

It is showing these two error mesages as

( ! ) 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

Line=22
$row=mysql_fetch_array($result);

Line=23
$count=mysql_num_rows($row);

What is I am doing wrong?

I just wanted to check, do you really store usernames in a column called mobile?
(it’s fine if you do, just never seen that before so thought i’d check it wasn’t a typo that was causing your query to fail)

Red :wink:

Yes i am using mobile number as user name.

Sponsor our Newsletter | Privacy Policy | Terms of Service