I’m trying to match up profiles in my MySQl database with the names and skillsets that are dropped into my droppable div, See HERE. I come across two problems one being the error mysql_fetch_array() expects parameter 1 to be resource, boolean given which I believe means my query is returning false. That takes me to the other problem, my $data not matching anything. How can I match the names and skills dropped into the droppable div with the names and skills in my database?
if (isset($_POST['data'])){
$data = $_POST['data'];
$query = mysql_query("SELECT * FROM gradesheet WHERE 'firstname','lastname','grade' LIKE '{$data}'");
while($row=mysql_fetch_array($query)){
$firstname=$row['firstname'];
$lastname=$row['lastname'];
$gradet=$row['grade'];
$user_id=$row['user_id'];
echo $firstname;
I used %Like% thinking it would give me a better chance than MATCH AGAINST. I would appreciate any knowledge or ideas on matching my query better and having it return something. As well as any tips in general.
You need to do a
LIKEfor each of the columns in yourWHEREstatement, and choose eitherANDorORto bring them together. The percent symbol%is a wildcard.You should also avoid using the
mysql_*PHP extensions as they have been deprecated; use PDO or mysqli instead. Aside from using deprecated extensions, your code is also wide open for a SQL injection attack. You should always filter data from request variables before sticking it into a query.