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

Home » Imported messages » comp.lang.php » Pulling my hair out
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Pulling my hair out [message #172404] Wed, 16 February 2011 17:51 Go to previous message
sheldonlg is currently offline  sheldonlg
Messages: 166
Registered: September 2010
Karma:
Senior Member
I have this TRIVIAL code and I am pulling my hair out because of it:

<?php
function getAllEvents() {
$sql = "SELECT * FROM events
WHERE eventDate > NOW()
ORDER BY eventDate LIMIT 4";
print $sql;
$result = mysql_query($sql);
var_dump($result)
$list = array();
while ($row = mysql_fetch_assoc($result)) {
$list[] = $row;
}
return $list;
}

with the two diagnostic included as above. I use the sequel statement
in phpmyadmin and it yields four entries and they are correct. However,
the var_dump results in boolean(false) and no results are extracted (of
course).

The column eventDate is configured as DATE.

I have tried replacing the NOW() with the result of date('Y-m-d'), and
played with many other things including turning things into Unix times.
Nothing worked. Removal of the WHERE clause produced results of the
the first four entries by date in the table.

I simply cannot see why the query works properly when used in
phpmyadmin, but fails here. (Yes, they are going to the same database
and same database table.) It seems so simple and is something I have
done a million times.

What can I be missing?

--
Shelly
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Welcome to PhoToZfAiR
Next Topic: PHP Malaysia Meetup 2011 : Framework Shootout
Goto Forum:
  

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

Current Time: Sun Dec 01 06:02:00 GMT 2024

Total time taken to generate the page: 0.03858 seconds