Page 1 of 1

Help needed Warning: mysql_fetch_array()

Posted: Thu Nov 19, 2009 6:01 pm
by patison13
Hi,
Im a newbie with PHP and mysql. I am doing or trying to do the code to retrieve data from the database where user input a name to search. I am getting Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\system\search_name.php on line 14 but i really could not find the mistake myself. Please help. This is my code:

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("login_password_manager", $con);

$tempname=$_POST["tempname"];

$result=mysql_query("SELECT (Name, Username, Password, Website) FROM login_details WHERE Name LIKE '%$tempname%'");

while($row1=mysql_fetch_array($result))
{
$Name = $row1["Name"];
$Username = $row1["Username"];
$Password = $row1["Password"];
$Website = $row1["Website"];

echo "$Name <br> $Username <br> $Password <br> $Website <br>";

};


mysql_close($con);
?>

I would be grateful for any comments,
thanks

Re: Help needed Warning: mysql_fetch_array()

Posted: Thu Nov 19, 2009 6:10 pm
by Weiry
Try changing your SQL to this:
$result=mysql_query("SELECT `Name`, `Username`, `Password`, `Website` FROM `login_details` WHERE `Name` LIKE '%{$tempname}%'");

Also please when posting, wrap your code using the [syntax=php][/syntax] or [syntax=php][/syntax] tags.

Re: Help needed Warning: mysql_fetch_array()

Posted: Thu Nov 19, 2009 6:18 pm
by patison13
Love you,
thanks very much. Its working now :D