/    Sign up×
Community /Pin to ProfileBookmark

can’t get this query to run. please help

I have this code

$query = “SELECT * FROM prayerconcerns where prayerconcern <> ” order by person”;

$result = @mysql_query ($query);
$num_rows = mysql_num_rows ($result);

I get error:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:Inetpubwwwrootprayerconcern.php on line 94

PHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:Inetpubwwwrootprayerconcern.php on line 94

If I change query to this:

$query = “SELECT * FROM prayerconcerns order by person”;

It works ok.

I guess it has something to do with escaping the characters but I can’t get figure it out.

Thanks,
Rut

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@SheldonDec 20.2005 — I think if you want to return all results where the feild is not empty try this,

[code=php]
$query = "SELECT * FROM prayerconcerns WHERE prayerconcerns != '' ORDER BY person";
$result = @mysql_query ($query);
[/code]



You are getting that error because your query is returning empty for your mysql_num_rows.

Next time please post your code in VB TAGS eg, [b][ php ] code [ /php ]
Copy linkTweet thisAlerts:
@rutledjauthorDec 20.2005 — I tried that combination also but get the same message.
Copy linkTweet thisAlerts:
@NogDogDec 20.2005 — Either <> or != should work. My best guess is either "prayerconcerns" or "person" is an invalid column name. Make sure they are spelled exactly as defined in the datbase, icluding upper or lower case letters. To get more indication as to where the problem is in the query, try:
[code=php]
$result = @mysql_query ($query) of die(mysql_error());
[/code]

(The '@' is suppressing error-reporting, so you need to check for errors yourself if you're going to use it.)
Copy linkTweet thisAlerts:
@bathurst_guyDec 20.2005 — just fixing a simple typo from NogDog[code=php] $result = @mysql_query ($query) or die(mysql_error()); [/code]
Copy linkTweet thisAlerts:
@NogDogDec 20.2005 — just fixing a simple typo from NogDog[code=php] $result = @mysql_query ($query) or die(mysql_error()); [/code][/QUOTE]
thx ?
×

Success!

Help @rutledj 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.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

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