dadamssg Posted January 24, 2009 Share Posted January 24, 2009 im trying to use this query to select events that are happening today...but im getting a parse error on this, can anybody tell me where it is? is it the * ? Link to comment https://forums.phpfreaks.com/topic/142206-solved-help/ Share on other sites More sharing options...
dadamssg Posted January 24, 2009 Author Share Posted January 24, 2009 oops haha..here it is $query = "SELECT * FROM test WHERE DATE(start) <= CURDATE() AND DATE(end) >= CURDATE() ORDER BY start DESC"; Link to comment https://forums.phpfreaks.com/topic/142206-solved-help/#findComment-744968 Share on other sites More sharing options...
PFMaBiSmAd Posted January 24, 2009 Share Posted January 24, 2009 What is the actual error message? Link to comment https://forums.phpfreaks.com/topic/142206-solved-help/#findComment-744971 Share on other sites More sharing options...
dadamssg Posted January 24, 2009 Author Share Posted January 24, 2009 Parse error: parse error in C:\wamp\www\PHPtutorials\showtoday.php on line 18 heres the whole code...im just trying to display all the info in tables <?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*/ $query = "SELECT * FROM test WHERE DATE(start) <= CURDATE() AND DATE(end) >= CURDATE() ORDER BY start DESC"; $result = mysqli_query($cxn,$query) 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> Link to comment https://forums.phpfreaks.com/topic/142206-solved-help/#findComment-744973 Share on other sites More sharing options...
PFMaBiSmAd Posted January 24, 2009 Share Posted January 24, 2009 That's a php parse error. A lot of php parse errors are due to a problem in the code prior to where the error is reported. The actual error cannot be detected because the parser does not know what you intended and it is only when it encounters something that is out of place in the current context that it generates the error message. You are missing a semi-colon ; on the line of code immediately prior to where the error is being reported. Link to comment https://forums.phpfreaks.com/topic/142206-solved-help/#findComment-744983 Share on other sites More sharing options...
dadamssg Posted January 24, 2009 Author Share Posted January 24, 2009 i always forget those freaking semicolons but that wasn't it heres the error Parse error: syntax error, unexpected T_VARIABLE in showtoday.php on line 17 Link to comment https://forums.phpfreaks.com/topic/142206-solved-help/#findComment-744994 Share on other sites More sharing options...
nuttycoder Posted January 24, 2009 Share Posted January 24, 2009 Missing semi's on these lines: or die ("Couldn't connect") echo " <tr> Link to comment https://forums.phpfreaks.com/topic/142206-solved-help/#findComment-745028 Share on other sites More sharing options...
dadamssg Posted January 24, 2009 Author Share Posted January 24, 2009 yeah i fixed that..nothin. I don't get it all... i am copying and pasting inside the quotes of the $query and putting them inside PhpMyAdmin and it works. this is driving me crazy <?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*/ $query = "SELECT * FROM test WHERE DATE(start) <= CURDATE() AND DATE(end) >= CURDATE() ORDER BY start DESC"; $result = mysqli_query($cxn,$query) 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> Link to comment https://forums.phpfreaks.com/topic/142206-solved-help/#findComment-745030 Share on other sites More sharing options...
dadamssg Posted January 24, 2009 Author Share Posted January 24, 2009 ok so i guess php didn't like the names of my variables so i changed them and it almost worked, now im getting a datetime error when i try to format the dates...the dates are in datetime in the database i dunno why im getting this error now...ive never formatted dates that come from datetime though the error: Warning: date_format() expects parameter 1 to be DateTime, string given in showtoday.php on line 25 Warning: date_format() expects parameter 1 to be DateTime, string given in showtoday.php on line 26 im also getting a session error..i dunno why thats comin up either: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at showtoday.php: in showtoday.php on line 9 Link to comment https://forums.phpfreaks.com/topic/142206-solved-help/#findComment-745044 Share on other sites More sharing options...
dadamssg Posted January 24, 2009 Author Share Posted January 24, 2009 fixed the session_start error...can someone please fix my date_format code and tell me how to display that in the <td>...PLEASE PLEASE Link to comment https://forums.phpfreaks.com/topic/142206-solved-help/#findComment-745058 Share on other sites More sharing options...
uniflare Posted January 24, 2009 Share Posted January 24, 2009 are you trying to format a timestamp into a readable date format? if so use date("d:m:y h:i:s",$timestamp); Link to comment https://forums.phpfreaks.com/topic/142206-solved-help/#findComment-745061 Share on other sites More sharing options...
nuttycoder Posted January 24, 2009 Share Posted January 24, 2009 You can format the date using strtotime: <?php echo "<td>".date('l F d, Y',strtotime($row['start']))."</td>\n"; echo "<td>".date('l F d, Y',strtotime($row['start']))."</td>\n"; ?> outputs like: Monday January 19, 2009 Link to comment https://forums.phpfreaks.com/topic/142206-solved-help/#findComment-745062 Share on other sites More sharing options...
dadamssg Posted January 24, 2009 Author Share Posted January 24, 2009 theirs usually always a simple way to do something i stress over for hours! thanks nuttycoder...exactly what i needed! Link to comment https://forums.phpfreaks.com/topic/142206-solved-help/#findComment-745067 Share on other sites More sharing options...
nuttycoder Posted January 24, 2009 Share Posted January 24, 2009 your welcome. it took me ages to get it work when i first looked at dates so your not alone :0) Link to comment https://forums.phpfreaks.com/topic/142206-solved-help/#findComment-745069 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.