dadamssg Posted January 31, 2009 Share Posted January 31, 2009 so wierd, i tried changing curdate() to curdatetime() but i guess that doesn't exist so i changed it back and no im getting errors when im formatting the $startt and $endt variables, but they were working fine before. any suggestions? oh and im getting an error with the session start() too, which i didn't get before <?php /* program: showevents.php*/ ?> <html> <body> <?php session_start(); include("caneck.inc"); $cxn = mysqli_connect($host,$user,$passwd,$dbname) or die ("Couldn't connect"); /*select todays events*/ $quer = "SELECT * FROM test WHERE DATE(start) <= CURDATE() AND DATE(end) >= CURDATE() ORDER BY start DESC"; $result = mysqli_query($cxn,$quer) or die ("Couldn't execute"); while($row = mysqli_fetch_assoc($result)) { /*Format dates to display*/ $startt = DATE_FORMAT($row['start'], '%b %e %Y %l %i %p'); $endt = DATE_FORMAT($row['end'], '%b %e %Y %l %i %p'); echo " <table border='3'>"; echo " <tr>"; echo "<td>{$row['eventid']}</td>"; echo "<td>{$row['created']}</td>"; echo "<td>{$row['title']}</td>"; echo "<td>{$row['event']}</td>"; echo "<td>{$row['description']}</td>"; echo "<td>{$row['location']}</td>"; echo "<td>/$$startt</td>"; echo "<td>/$$endt</td>"; echo "</tr></table>"; } ?> </body></html> Quote Link to comment Share on other sites More sharing options...
revraz Posted January 31, 2009 Share Posted January 31, 2009 By having session_start under your HTML tags, you would always get errors. Quote Link to comment Share on other sites More sharing options...
dadamssg Posted January 31, 2009 Author Share Posted January 31, 2009 thanks, i just fixed that. works now but what about those stupid dates? Warning: date_format() expects parameter 1 to be DateTime, string given on line 25 all the dates in the database are in the datetime format Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted January 31, 2009 Share Posted January 31, 2009 The php date_format() function expects - Parameters object Procedural style only: A DateTime object returned by date_create() Quote Link to comment Share on other sites More sharing options...
dadamssg Posted January 31, 2009 Author Share Posted January 31, 2009 how should i go about formatting and displaying the dates if date_format() isn't working? i don't get it...it was working exactly as-is a while ago Quote Link to comment Share on other sites More sharing options...
printf Posted January 31, 2009 Share Posted January 31, 2009 change your query, let the database do it... // // // // $quer = "SELECT eventid, created, title, event, description, location, DATE_FORMAT(start, '%b %e %Y %l %i %p') AS start, DATE_FORMAT(end, '%b %e %Y %l %i %p') AS end FROM test WHERE DATE(start) <= CURDATE() AND DATE(end) >= CURDATE() ORDER BY start DESC"; // // // // Quote Link to comment Share on other sites More sharing options...
dadamssg Posted January 31, 2009 Author Share Posted January 31, 2009 how do i make the query do that? Quote Link to comment Share on other sites More sharing options...
printf Posted January 31, 2009 Share Posted January 31, 2009 just like I wrote above.. Quote Link to comment Share on other sites More sharing options...
dadamssg Posted January 31, 2009 Author Share Posted January 31, 2009 ...you didn't write anything above...all i see is a horizontal scroll bar in your post Quote Link to comment Share on other sites More sharing options...
printf Posted January 31, 2009 Share Posted January 31, 2009 I see it, let me add some line breaks and see it it shows up... Quote Link to comment Share on other sites More sharing options...
dadamssg Posted January 31, 2009 Author Share Posted January 31, 2009 wow that worked perfectly, thank you! Quote Link to comment Share on other sites More sharing options...
dadamssg Posted January 31, 2009 Author Share Posted January 31, 2009 whats the symbol i need to put to display the AM PM to am pm for the sql query? Quote Link to comment Share on other sites More sharing options...
printf Posted January 31, 2009 Share Posted January 31, 2009 It should be... %p Here is a guide of all the specifier characters, bookmark it... MySQL Date Format Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.