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
Help needed Warning: mysql_fetch_array()
Moderator: General Moderators
Re: Help needed Warning: mysql_fetch_array()
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.
$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()
Love you,
thanks very much. Its working now
thanks very much. Its working now