0

I have a sql statement as follows SELECT * FROM user WHERE 'uName' LIKE '%$var%';

Purpose of the code is to do search of an item based on a string inputted by the user. here i my full code...

$var = $_POST['x'] ;

$dbhost = 'localhost';
   $dbuser = 'turningp_dbuser';
   $dbpass = 'moonda@1190';
   $conn = mysql_connect($dbhost, $dbuser, $dbpass);
   mysql_select_db("turningp_erp");
   $query = mysql_query("SELECT * FROM user WHERE 'uName' LIKE '%$var%' ");

     while($array = mysql_fetch_array($query))
{

      $a = $array['uName'];

      echo "<h1><a href='modify.php?q=$a'>$a</a></h1><br/> ";
     
}

But the script fetches all the data in the table irrespective of any string I enter.

0 Answers0