Connecting Tech Pros Worldwide Forums | Help | Site Map

list() query not working

Newbie
 
Join Date: May 2009
Posts: 21
#1: Jun 16 '09
Hello,

When I run the code below when $entry = miami.com, I get the following error message:

Quote:
SELECT COUNT(*) FROM #&*+ WHERE `site` LIKE 'miami.com':You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
It looks like I'm not correctly defining $table. Any ideas how I could do that?

Thanks in advance,

John


Expand|Select|Wrap|Line Numbers
  1. $result = mysql_query("SHOW TABLES FROM feather") 
  2. or die(mysql_error()); 
  3.  
  4.  
  5. while(list($table)= mysql_fetch_row($result))
  6. {
  7.   $sqlA = "SELECT COUNT(*) FROM $table WHERE `site` LIKE '$entry'";
  8.   $resA = mysql_query($sqlA) or die("$sqlA:".mysql_error());
  9.   list($isThere) = mysql_fetch_row($resA);
  10.   if ($isThere)
  11.   {
  12.      $table_list[] = $table;
  13.   }
  14. }

hsriat's Avatar
Expert
 
Join Date: Jan 2008
Location: Bath, UK
Posts: 1,609
#2: Jun 16 '09

re: list() query not working


I think '%' is missing.
http://dev.mysql.com/doc/refman/5.0/...-matching.html
prabirchoudhury's Avatar
Familiar Sight
 
Join Date: May 2009
Location: Wellington, New Zealand
Posts: 152
#3: Jun 16 '09

re: list() query not working


hey.

If no wildcard characters (%%, …, _) are used then there should be no difference in
performance between
Expand|Select|Wrap|Line Numbers
  1. “… WHERE site='$entry' ” and “..WHERE site LIKE '$entry'”
the two queries . so , I think you need to check with your query and passing variable matches.


:)
Reply