MYSQL ERROR

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
van95
Forum Newbie
Posts: 2
Joined: Fri Apr 07, 2017 10:30 am

MYSQL ERROR

Post 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>
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: MYSQL ERROR

Post 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.
van95
Forum Newbie
Posts: 2
Joined: Fri Apr 07, 2017 10:30 am

Re: MYSQL ERROR

Post by van95 »

i got it from youtube, and thanks for your advice
Post Reply