0

here is my source code about login into a web

<?php 
/*
$login=$_POST['login'];
if($login=="Login")
{ */
    $connect==mysql_connect("localhost","root","");

    if(!connect)
    {
       die ('Cannot connect to the database'.mysql_error()); }
  
mysql_select_db("firstdbs",$connect);

$in_user= $_POST['username'];
$in_pass=$_POST['password'];

// To protect MySQL injection
 $in_user = stripslashes($in_user);
 $in_pass = stripslashes($in_pass);
 $in_user = mysql_real_escape_string($in_user);
 $in_pass = mysql_real_escape_string($in_pass);
 
$sql="SELECT * FROM login WHERE de_user='$in_user' and de_pass='$in_pass' ";

$result= mysql_query($sql);
$count=mysql_num_rows($result);  print($count);
if($count==1)
{
echo "dsfaf";
}
else
echo "Wrong something! Please re-login";


?>

but when I open it through the browser it raised some warnings like:

Warning: mysql_select_db() expects parameter 2 to be resource, null given in C:\xampp\htdocs\EX1\page1.php on line 12

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\EX1\page1.php on line 26
Wrong something! Please re-login
I do not know the reason.
Please help me!

3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by poojamakhija
0

You only need one = on your mysql_connect statement.

oh, thank you! I also found this mistake several minutes ago!

0

oh! thank you very much!I also found this mistake several minutes ago!
^ ^

-1
Give single "=" sign instead of double "==" in follwing line:
$connect==mysql_connect("localhost","root","");
This surly works
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.