(Q. 2) Php fetching users from mysql related question?

Mit Chauhan

New member
JAI MATADI all ..


m trying to fetch the users from the mysql database using my php code ..

in which if the user only type the particular surname or name then also he/she can see the users if they are available ..

suppose my name -- (if you type "MIT" then also you can see me at fetching and if you type "CHAUHAN" then also you can fetch me)

but it seems to be not working for me in my code .. here is my code ..

-----------------------------------------------------------------------
<form name="f1" method="post">
Enter the Name <input type="text" name="name" />
<br />
<input type="submit" name="submit" value="Search" />
</form>


<?php

if(isset($_POST["submit"]))
{
$users = $_POST["name"];
//echo "hello";
mysql_connect("localhost","root","");
mysql_select_db("alldatabase");
$qry = "select * from signup where pname LIKE %'$users'%";
$rs = mysql_query($qry);
while($rows = mysql_fetch_array($rs))
{
$users = $rows["pname"];
echo $users;
}

}

?>
-----------------------------------------------------------------------

but m getting an ERROR when i click on a button ..
if i leave it blank and clicking on button and even if m writing something in a textbox Assume writing "Chauhan" in textbox and then clicking on button m getting only this error ..
----------------------------------------------------------------------------------------------
"Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given"

tell me experts whats wrong m doing here ..
the same question i have just asked b4 here .. and i got enough replies but not getting the results ..

http://answers.yahoo.com/question/index?qid=20110120030820AAJ4WVT
 
Back
Top