/    Sign up×
Community /Pin to ProfileBookmark

list() query not working

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

[/QUOTE]

It looks like I’m not correctly defining $table. Any ideas how I could do that?

Thanks in advance,

John

[CODE]$result = mysql_query(“SHOW TABLES FROM feather”)
or die(mysql_error());

while(list($table)= mysql_fetch_row($result))
{
$sqlA = “SELECT COUNT(*) FROM $table WHERE `site` LIKE ‘$entry'”;
$resA = mysql_query($sqlA) or die(“$sqlA:”.mysql_error());
list($isThere) = mysql_fetch_row($resA);
if ($isThere)
{
$table_list[] = $table;
}
}[/CODE]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@MindzaiJun 16.2009 — list() returns void so it is not a good idea to use it as an expression in a while loop.

Note you could also use the mysql_list_tables() function instead of the query.

It seems like what you are trying to do is a bit convoluted too - why not use a join instead of queries in loops?
Copy linkTweet thisAlerts:
@ShortsJun 16.2009 — Also, in your loop, do a :

[code=php]
echo $sqlA,"n";
[/code]


Right after you declare it to see what the query being sent actually is.
×

Success!

Help @ArizonaJohn spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...