visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
316 experts, 1194 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Databases :: MySql :: DATE_FORMAT problems


By: Squibi U.S.A.  Date: 17/03/2003 00:00:00  English  Points: 25 Status: Answered
Quality : Excellent
Hi,

I am curious as to whats happening with this code. Every time I run it no results are returned. Any format problems anyone can see?

$date = "SELECT DATE_FORMAT(move_in, '%m %d %y') FROM ilive.pri_listings WHERE listing_id = ".$listing_id;
$date2 = mysql_query($date);
$date3 = mysql_fetch_array($date2);

echo "<font face = 'arial' size = '2' color = '#0000FF'><b>Available (mm/dd/yy):</b></font><font face = 'arial' size = '2'>&nbsp;&nbsp;".$date3['move_in']."</font>";

Is there any obvious errors anyone can see?

Thanks

By: Squibi Date: 17/03/2003 19:10:00 English  Type : Comment
Never Mind,

Figured it out,

echo $date3[0];

Worked

Whoever responds the quickest can have these points :)
By: VGR Date: 17/03/2003 19:20:00 English  Type : Answer
yes, the story is that your column is not named 'move_in' but 'DATE_FORMAT(move_in, '%m %d %y') ' - always try first in the mySql console to see this kind of stupid mistake.

You should take the habit of naminf your computed cilumns, like in here :
$date = "SELECT DATE_FORMAT(move_in, '%m %d %y') AS a FROM ilive.pri_listings WHERE listing_id = ".$listing_id;

echo "<font [...] ".$date3['a']."</font>";
By: Squibi Date: 17/03/2003 19:23:00 English  Type : Comment
Excellent tip, I wasn't aware of the AS notation


By: VGR Date: 17/03/2003 19:58:00 English  Type : Comment
I wanted to merit the points ;-)

Do register to be able to answer

EContact
browser fav
page generated in 580.979110 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page