Gem Posted March 15, 2009 Share Posted March 15, 2009 Ummm ... please would someone take a look at this... I think I messed it up... <?php // assumes all the data for the current year is to be retrieved $con = mysql_connect("80.94.196.33","gem","landseer"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("bssql", $con); $result = mysql_query( "select *,MONTHNAME(date) as mn from diary where year(date) = year(curdate()) order by date"); $previous_month = ""; // initialize variable to detect change in month name while($row = mysql_fetch_array($result)) { if($row['mn'] != $previous_month){ ?><H1><?php echo $row['mn'] . '<br />'; ?> </H1> <?php $previous_month = $row['mn']; } ?><H2><?php echo nl2br($row['event']); ?> </H2> <H3><?php $date = explode("-",$row['date']); $date = date("jS F Y",mktime(0,0,0,$date[1],$date[2],$date[0])); echo nl2br '.$date.'; ?> </H3> <?php echo nl2br($row['details']); echo "<br />##########################################"; echo "<br /><br />"; } ?> Error: PHP Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in d:\webspace\bradleystokejudoclub.co.uk\wwwroot\diary.php on line 171 Line 171 is: echo nl2br '.$date.'; ?> </H3> (supposidly!) Any ideas what I've done, or more importantly ... how I fix it??? Thanks a million ... x Link to comment https://forums.phpfreaks.com/topic/149452-solved-i-messed-up-the-code/ Share on other sites More sharing options...
shlumph Posted March 15, 2009 Share Posted March 15, 2009 nl2br is a function, so try this: echo nl2br('.$date.'); ?> </H3> And PLEASE, PLEASE, format your code better! <?php ?><H1><?php echo $row['mn'] . '<br />'; ?> </H1> <?php LOL! Link to comment https://forums.phpfreaks.com/topic/149452-solved-i-messed-up-the-code/#findComment-784945 Share on other sites More sharing options...
Gem Posted March 15, 2009 Author Share Posted March 15, 2009 LOL - Thanks mate. Only works if I do this: echo nl2br($date); ?> </H3> I'm very new to this game (like I only started a week ago!) I'm learning as I'm doing ... I don't really know what I'm doing at all LOL Thanks for your help though ... Is there anywhere with DO/DON'Ts on formatting code??? XXXXX Link to comment https://forums.phpfreaks.com/topic/149452-solved-i-messed-up-the-code/#findComment-784954 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.