Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #1778

Re: You have an error in your SQL syntax;

From The Natural Philosopher <tnp@invalid.invalid>
Newsgroups comp.lang.php
Subject Re: You have an error in your SQL syntax;
Date 2011-05-22 21:21 +0100
Organization albasani.net
Message-ID <irbr81$ccp$1@news.albasani.net> (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>

Show all headers | View raw


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

Then the original query failed.

If you stick in some debug like $query=(whatever your query is);
echo $query;

then you can cut and paste that into an interactive mysql session and 
test it.

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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