FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » You have an error in your SQL syntax;
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: You have an error in your SQL syntax; [message #174130 is a reply to message #174129] Sun, 22 May 2011 20:21 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
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.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Detecting Redirected Output
Next Topic: Stats comp.lang.php (last 7 days)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 04:40:13 GMT 2024

Total time taken to generate the page: 0.05702 seconds