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

Home » Imported messages » comp.lang.php » query with empty resultset (but the same one, used in phpmyadmin, gives results!!)
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: query with empty resultset (but the same one, used in phpmyadmin, gives results!!) [message #175354 is a reply to message #175349] Sat, 10 September 2011 13:00 Go to previous message
Norman Peelman is currently offline  Norman Peelman
Messages: 126
Registered: September 2010
Karma:
Senior Member
On 09/10/2011 06:41 AM, SatBoy78 wrote:
> Hi, I'm having some problems with a query, that gives results if used
> in phpmyadmin, but when I use it in my php page I'll get an empty
> resultset
>
> the query is
>
> select * from brucisys_homecalciobet.bollahome where (DAY(Data)
> between 9 and 11) and (MONTH(Data) = 9) and (YEAR(Data) = 2011)
>
> and, as told, gives some results
>
>
> in my php page I've written this:
>
> $dayStart=9;
> $dayEnd=11;
> $month=09;
> $year=2011;
>
> $rs0 = mysql_query("select * from brucisys_homecalciobet.bollahome
> where (DAY(Data) between ".$dayStart." and ".$dayEnd.") and
> (MONTH(Data) = ".$month.") and (YEAR(Data) = ".$year.")");
>
> but the resultset is empty; infact I've done this little test
>
> $returned_rows = mysql_num_rows ($rs0); echo "n. ".$returned_rows;
>
> and it shows n. 0
>
>
> Do you have any idea? wherei'm wrong?
>
> Thanks a lot for your help
>
> Have a nice day

I see you found the problem... but as a suggestion you may (or may
not) find:

$rs0 = mysql_query("SELECT * FROM brucisys_homecalciobet.bollahome
WHERE (DAY(Data) BETWEEN $dayStart AND $dayEnd) AND
(MONTH(Data) = $month) AND (YEAR(Data) = $year)");

... a little easier to read. I like to capitalize all SQL keywords
and you can get rid of the pointless string concatination. It's not
needed. You can take a look at:

http://us3.php.net/manual/en/language.operators.string.php

....for examples.

--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: HOW TO: Spice up Your Site With Simple PHP
Next Topic: Stats comp.lang.php (last 7 days)
Goto Forum:
  

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

Current Time: Thu Nov 28 08:04:22 GMT 2024

Total time taken to generate the page: 0.06823 seconds