0
$query = mysql_query ("SELECT * FROM $table WHERE filename LIKE '%" . 
$searchq . "%' OR filename1 LIKE '%" .
$searchq . "%' AND category = '" . $_SESSION['action']."'") or 
die ("could not search");

Every time my query gives the output Could not search!!

where $table is variable for table_name, filename and filename1 are filednames of the same table respectively.

Thank you .

Hameed
  • 2,227
  • 1
  • 21
  • 31
  • [Please, don't use `mysql_*` functions to write new code.](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) – quietmint Dec 20 '13 at 04:21
  • Try by giving the table name instead of the $table and let me know. – Code Lღver Dec 20 '13 at 04:22
  • Instead of (or at least before) `die()`, please call [`mysql_error()`](http://www.php.net/mysql_error) to see the actual error you're getting. Post the query you're running (e.g., echo the query after substituting the parameters) and the error message so we can see the exact problem. – quietmint Dec 20 '13 at 04:25
  • Format your query better here and also in your own code. This a lot of time helps in finding out the problems. Also use `mysql_error()` to find out the actual problem – Hameed Dec 20 '13 at 04:32
  • Thnx for the suggest. – user2893605 Dec 20 '13 at 06:25

1 Answers1

0

You will have a syntax problem, try:

$query = mysql_query ("SELECT * FROM $table WHERE (filename LIKE '%$searchq%' OR filename1 LIKE '%$searchq%') AND category = '" .$_SESSION['action']."'" ) or die (mysql_error()) ;
Ignacio Ocampo
  • 2,693
  • 1
  • 20
  • 31