Page 1 of 1

MYSQL ERROR

Posted: Fri Apr 07, 2017 10:43 am
by van95
hi there am new here as well as on database lessons, i was trying to search data in my database in xampp but i get this error "mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\login\search.php on line 15"
my codes are shown below please help me how can i fix that error, thanks in advance
<!DOCTYPE html>
<html>
<head>
<title>search</title>
</head>
<body>

<?php
mysql_connect("localhost", "root", "") or die ("bad connection");
mysql_select_db("test");

$search = mysql_real_escape_string(trim($_POST['searchterm']));
$find_v = mysql_query("select * from 'videos' where 'keyword' like '%$search%' ");
while($row = mysql_fetch_assoc($find_v))
{

$name = $row['name'];

echo "$name<br/>";


};

?>
</body>
</html>

Re: MYSQL ERROR

Posted: Fri Apr 07, 2017 11:03 am
by requinix
That error message almost always means there was a syntax error in your SQL query. Where did you get it from? The lesson? They should also be teaching you the correct way to put table and column names in a query...

Another problem: the mysql_* functions are bad and old and have been totally removed from current versions of PHP. You need to find something that teaches you about using PDO instead.

Re: MYSQL ERROR

Posted: Fri Apr 07, 2017 12:06 pm
by van95
i got it from youtube, and thanks for your advice