php - Getting a syntax error, unexpected end of file error but cant seem to find error -
this question has answer here:
- php parse/syntax errors; , how solve them? 11 answers
i keep getting parse error: syntax error, unexpected end of file error @ line 167. have gone through code many times , can't seem find i'm missing. i've checked of brackets , statements , don't find off. can error possibly
#!/usr/local/bin/php -d display_errors=stdout <?php date_default_timezone_set('america/los_angeles'); $time_stamp = time(); $disp = $_get['time_stamp']; if($disp == "previous") $time_stamp -= 43200; else if($disp == "next") $time_stamp += 43200; $today = date("d, f j, y, g:i a",$time_stamp); $start_hour_offset = -3; $end_hour = 12; $table = "event_table"; $field1 = "person"; $field2 = "time"; $field3 = "event_title"; $field4 = "event_message"; try { $db = new sqlite3('dbalexmf14.db'); } catch (exception $exception) { echo '<p>there error connecting database!</p>'; if ($db) { echo $exception->getmessage(); } } /**function get_events($name, $ts){ $sql = "select * event_table person = $name, time = $ts || time <= $ts + 3600"; print "$sql"; $result = $db->query($sql); while($record=$result->fetcharray()) { $title = $record['event_title']; $message = $record['event_message']; $a_events= $title. " ". $message; }**/ function get_hour_string($time_stamp){ $hour = date("g", $time_stamp); $am_or_pm = date("a",$time_stamp); return "$hour.00$am_or_pm"; } print('<?xml version = "1.0" encoding="utf-8"?> '); ?> <!doctype html public "-//w3c//dtd xhtml 1.1//en" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd"> <html> <head> <title>calendar</title> <link rel="stylesheet" type="text/css" href="calendar.css" /> </head> <body> <div class="container"> <h1>bruin family schedule <?php print"$today" ?> </h1> <table id="event_table"> <?php // print header print " <tr> \n"; print " <th class='hr_td_'> </th> <th class='table_header'>alex</th><th class='table_header'>ashton</th><th class='table_header'>joshua</th> \n"; print " </tr> \n"; ($i=0; $i<=$end_hour;++$i) { $hour_string = get_hour_string($time_stamp + $i*3600); if ($i%2 == 0){ print "<tr class='even_row'>\n"; print "<td class='hr_td'>$hour_string</td> <td> </td> <td> </td> <td></td>\n"; } if ($i%2 !=0){ print "<tr class='odd_row'>\n"; print "<td class='hr_td'>$hour_string</td> <td> </td> <td> </td> <td> </td>\n"; } $sql = "select * event_table person = 'alex', time = $ts || time <= $ts + 3600"; print "$sql"; $result = $db->query($sql); $a_events=""; $j_events=""; $ah_events=""; while($record=$result->fetcharray()) { $title = $record['event_title']; $message = $record['event_message']; $a_events= $title. " ". $message; } $sql = "select * event_table person = 'ashton', time = $ts || time <= $ts + 3600"; print "$sql"; $result = $db->query($sql); while($record=$result->fetcharray()) { $title = $record['event_title']; $message = $record['event_message']; $ah_events= $title. " ". $message; $sql = "select * event_table person = 'joshua', time = $ts || time <= $ts + 3600"; print "$sql"; $result = $db->query($sql); while($record=$result->fetcharray()) { $title = $record['event_title']; $message = $record['event_message']; $j_events= $title. " ". $message; //$a_events = get_events("alex", $time_stamp); //$ah_events = get-events("ashton", $time_stamp); //$j_events = get_events("joshua", $time_stamp); print "<td>$a_events</td><td>$j_events</td><td>$ah_events</td>"; print " </tr> \n"; ?> </table> <div> <form id="prev" method="get" action="calendar2.php"> <p> <input type="hidden" name="time_stamp" value='previous' /> <input type="submit" value="previous"/> </p> </form> <form id="next" method="get" action="calendar2.php"> <p> <input type="hidden" name="time_stamp" value='next' /> <input type="submit" value="next"/> </p> </form> <form id="today" method="get" action="calendar2.php"> <p> <input type="submit" value="today"/> </p> </form> </div> </div> </body> </html>
it seems not closed curly braces in code. try following
<?php date_default_timezone_set('america/los_angeles'); $time_stamp = time(); $disp = $_get['time_stamp']; if($disp == "previous") $time_stamp -= 43200; else if($disp == "next") $time_stamp += 43200; $today = date("d, f j, y, g:i a",$time_stamp); $start_hour_offset = -3; $end_hour = 12; $table = "event_table"; $field1 = "person"; $field2 = "time"; $field3 = "event_title"; $field4 = "event_message"; try { $db = new sqlite3('dbalexmf14.db'); } catch (exception $exception) { echo '<p>there error connecting database!</p>'; if ($db) { echo $exception->getmessage(); } } /**function get_events($name, $ts){ $sql = "select * event_table person = $name, time = $ts || time <= $ts + 3600"; print "$sql"; $result = $db->query($sql); while($record=$result->fetcharray()) { $title = $record['event_title']; $message = $record['event_message']; $a_events= $title. " ". $message; }**/ function get_hour_string($time_stamp){ $hour = date("g", $time_stamp); $am_or_pm = date("a",$time_stamp); return "$hour.00$am_or_pm"; } print('<?xml version = "1.0" encoding="utf-8"?> '); ?> <!doctype html public "-//w3c//dtd xhtml 1.1//en" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd"> <html> <head> <title>calendar</title> <link rel="stylesheet" type="text/css" href="calendar.css" /> </head> <body> <div class="container"> <h1>bruin family schedule <?php print"$today" ?> </h1> <table id="event_table"> <?php print " <tr> \n"; print " <th class='hr_td_'> </th> <th class='table_header'>alex</th><th class='table_header'>ashton</th><th class='table_header'>joshua</th> \n"; print " </tr> \n"; ($i=0; $i<=$end_hour;++$i) { $hour_string = get_hour_string($time_stamp + $i*3600); if ($i%2 == 0){ print "<tr class='even_row'>\n"; print "<td class='hr_td'>$hour_string</td> <td> </td> <td> </td> <td></td>\n"; } if ($i%2 !=0){ print "<tr class='odd_row'>\n"; print "<td class='hr_td'>$hour_string</td> <td> </td> <td> </td> <td> </td>\n"; } $sql = "select * event_table person = 'alex', time = $ts || time <= $ts + 3600"; print "$sql"; $result = $db->query($sql); $a_events=""; $j_events=""; $ah_events=""; while($record=$result->fetcharray()) { $title = $record['event_title']; $message = $record['event_message']; $a_events= $title. " ". $message; } $sql = "select * event_table person = 'ashton', time = $ts || time <= $ts + 3600"; print "$sql"; $result = $db->query($sql); while($record=$result->fetcharray()) { $title = $record['event_title']; $message = $record['event_message']; $ah_events= $title. " ". $message; $sql = "select * event_table person = 'joshua', time = $ts || time <= $ts + 3600"; print "$sql"; $result = $db->query($sql); while($record=$result->fetcharray()) { $title = $record['event_title']; $message = $record['event_message']; $j_events= $title. " ". $message; //$a_events = get_events("alex", $time_stamp); //$ah_events = get-events("ashton", $time_stamp); //$j_events = get_events("joshua", $time_stamp); print "<td>$a_events</td><td>$j_events</td><td>$ah_events</td>"; print " </tr> \n"; } } } ?> </table> <div> <form id="prev" method="get" action="calendar2.php"> <p> <input type="hidden" name="time_stamp" value='previous' /> <input type="submit" value="previous"/> </p> </form> <form id="next" method="get" action="calendar2.php"> <p> <input type="hidden" name="time_stamp" value='next' /> <input type="submit" value="next"/> </p> </form> <form id="today" method="get" action="calendar2.php"> <p> <input type="submit" value="today"/> </p> </form> </div> </div> </body> </html>
Comments
Post a Comment