/    Sign up×
Community /Pin to ProfileBookmark

‘-‘ in a msql_fetch_array

[url]http://accessjdm.com[/url]

[code=php]$sql2 = mysql_query(“SELECT id FROM $row[lower]”);
$count = 0;
while($row2 = mysql_fetch_array($sql2))
{$count++;}
echo “$count)</li>n”;
$total += $count;[/code]

all of the others work, but when $row[lower]=”ms-dos”, i get this error:

mysql_fetch_array(): supplied argument is not a valid MySQL result resource

i even changed it to this after refreshing my memory on php functions:

[code=php]echo mysql_num_rows(mysql_query(“SELECT id FROM $row[lower]”)).”)n”;[/code]

why is that? is the ‘-‘ screwing things up?

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 17.2005 — I think not quoting your array index is causing the problem. This should be safer:
[code=php]
$sql2 = mysql_query("SELECT id FROM {$row['lower']}");
[/code]
Copy linkTweet thisAlerts:
@JDM71488authorMar 17.2005 — [code=php]echo mysql_num_rows(mysql_query("SELECT id FROM {$row['lower']}")).")n";[/code]
works for all but "ms-dos"... ?
Copy linkTweet thisAlerts:
@NogDogMar 17.2005 — Maybe backticks for the column name?....
[code=php]
mysql_query("SELECT id FROM {$row['lower']}")
[/code]
Copy linkTweet thisAlerts:
@JDM71488authorMar 17.2005 — parse error []... my fault... it worked

the
was outside the query... it gets pretty confusing with all of the character hierarchy...

thank you!
×

Success!

Help @JDM71488 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...