0

Hi, so this is the most basic thing ever but i am having trouble with it. idk if its because of the code or it just can't be done or idk something. I am trying to retrieve from database by clicking on a [input type submit] button but I am getting Fatal Error near my WHERE syntax.

<input type="submit" name="bf" class="btn btn-default filter-button" value="Bowls & Feeders">

<?php
   if(isset($_GET['bf'])){
      $cat = "Bowls & Feeders";

      $query = $conn->prepare("SELECT * FROM table WHERE type = ':type");
      $query->bindParam(':type', $cat, PDO::PARAM_STR);
      $query->execute();
      $result = $query->fetch(PDO::FETCH_ASSOC);              
    }
?>

I have stared at the code for awhile that i might go blind. please help. thank you in advance.

Edited by random_1

3
Contributors
3
Replies
25
Views
7 Months
Discussion Span
Last Post by AndrisP
0

Well, it was a missing apostrophe(?) i that what you call this ' ? but now its just blank.

0

Use of & inside REQUEST variable is not good idea. I suggest replace to and but if you realy want to use it then use as &amp;

Edited by AndrisP

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.