Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #1779
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: You have an error in your SQL syntax; |
| Date | 2011-05-22 16:21 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <irbr8b$g5u$1@dont-email.me> (permalink) |
| References | <1b4559f6-a3bc-4a87-95e1-adefc83b7286@a10g2000vbz.googlegroups.com> <4dd943d1$0$49177$e4fe514c@news.xs4all.nl> <ab86cb26-0606-483d-8866-fdf54974c8e7@32g2000vbe.googlegroups.com> |
On 5/22/2011 4:11 PM, Co wrote:
> On 22 mei, 19:11, Luuk<L...@invalid.lan> wrote:
>> On 22-05-2011 16:01, Co wrote:
>>
>>> Hi all,
>>
>>> I run a query based on the input in a listbox.
>>> The query looks for users from a certain country.
>>> When no users are from the chosen country I get a error message.
>>> Is there no way to check if there are records in the query before
>>> trying to output
>>> so we only get a message saying: No records for this search.... or
>>> something like it.
>>
>>> Regards
>>> Marco
>>
>> I hope you know that there is a great MANUAL online at:http://www.php.net
>>
>> It has this great info:http://php.net/manual/en/function.mysql-num-rows.php
>>
>> --
>> Luuk
>
> Thanks Luuk,
> I didn't know.
> Anyways I tried an example from the page:
>
> $num_rows = mysql_num_rows($sql2);
> if($num_rows<> 0) {
> while($row = mysql_fetch_array($sql2)) { ......
>
> else {
> print ("<p>No records for this search were found.</p>");
> }
>
> But I still get the error line saying:
> Warning: mysql_num_rows(): supplied argument is not a valid MySQL
> result resource
>
> Marco
It means there was a problem with your SQL statement.
You need to check the results of mysql_query(), and if it is false,
determine why the SQL statement was in error.
You should ALWAYS check the return value of mysql_query() to ensure
worked correctly.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
You have an error in your SQL syntax; Co <vonclausowitz@gmail.com> - 2011-05-22 07:01 -0700
Re: You have an error in your SQL syntax; Luuk <Luuk@invalid.lan> - 2011-05-22 19:11 +0200
Re: You have an error in your SQL syntax; Co <vonclausowitz@gmail.com> - 2011-05-22 13:11 -0700
Re: You have an error in your SQL syntax; The Natural Philosopher <tnp@invalid.invalid> - 2011-05-22 21:21 +0100
Re: You have an error in your SQL syntax; Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-22 16:21 -0400
Re: You have an error in your SQL syntax; Luuk <Luuk@invalid.lan> - 2011-05-22 22:35 +0200
Re: You have an error in your SQL syntax; Co <vonclausowitz@gmail.com> - 2011-05-22 13:56 -0700
Re: You have an error in your SQL syntax; Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-22 17:16 -0400
Re: You have an error in your SQL syntax; Co <vonclausowitz@gmail.com> - 2011-05-22 14:22 -0700
csiph-web