Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am getting this error while i running the code
mysql_fetch_array() expects parameter 1 to be resource boolean given.

XML
<?php

$con=mysql_connect("localhost","username","password");
if(!$con)
{
die("connectivity error".mysql_error());
}
mysql_select_db("cool",$con);
if(isset($_POST['ok']))
{
$s="select * from login where username='$_POST[uname]' and password='$_POST[pwd]'";
$name=mysql_query($s) or die(mysql_error());
$i=0;
    while($row=mysql_fetch_array($name))
    {
    $i++;

    }

    if($i>0)
    {

    echo("hi");
        }
        else
        {
        echo "<script language='javascript'>";
        echo "alert('sorry you cant come to me');";
        echo "</script>";
        }
}
?>
<html>
<head></head>
<body>
<form action="" method="post">
<input type="text" name="uname"/>
<input type="text" name="pwd"/>
<input type="submit" name="ok" value="Login"/>
</form>
</body>
</html>
</body>

pls give the correct coding
Posted

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900