Our site is externally hosted. It's using Drupal (very outdated and the higher ups are reluctant to upgrade). We have several pages that connect to a database on a different server (hosted by a different company) to display scheduling information.
Recently the company hosting our Drupal site upgraded PHP and it blew out all of our pages accessing the database. After much wrangling, I believe that I've corrected the connection issues but now I'm getting the following error:
Parse error: syntax error, unexpected 'include' (T_INCLUDE) in /imedia/users/sc-drupal/htdocs/includes/common.inc(1695) : eval()'d code on line 1
Here are the first few lines of the common.inc file
line 1:<?php
line 2:// $Id: common.inc,v 1.756.2.96 2010/08/11 20:35:47 goba Exp $
line 3:
line 4:/**
line 5: * @file
line 6: * Common functions that many Drupal modules will need to reference.
line 7: *
line 8: * The functions that are critical and need to be available even when serving
line 9: * a cached page are instead located in bootstrap.inc.
line 10:*/
line 11:/**
line 12: * Return status for saving which involved creating a new item.
line 13: */
line 14: define('SAVED_NEW', 1);
...
For those that might claim that this is a duplicate questions, please see the notes, below. include
is not anywhere near line 1!
My thoughts are that the common.inc
file is not the problem. All other pages are working so I would think that would point the problem to the PHP file for the page, which has the error.
The problem with that: nothing was changed in that file either.
Can anyone point me in a direction to trouble shoot this?
<?php
$page_name = substr($_SERVER["REQUEST_URI"],0,strpos($_SERVER["REQUEST_URI"],"?"));
// START TIME when file loads
$start_time = getmicrotime();
/***************************************************
SCRUB USER SUBMITTED DATA
Do it once here, rather than multiple times in each of the included files
***************************************************/
if(preg_match("/\w/",$_GET[searchInput]))
{
$_GET[searchInput]=trim($_GET[searchInput]);
}
$_GET[search_type] = strip_tags($_GET[search_type]);
foreach($_GET as $gk=>$gv) // 'gk' == 'get key', 'gv'== 'get value'
{
//echo "$gk $gv<br>";
$_GET[$gk] = addslashes(strip_tags($gv));
}
$startMoAry= explode(" " , $_GET[startMonth]);
$endMoAry= explode(" " , $_GET[endMonth]);
$start_ts=strtotime($startMoAry[0]."".$_GET[startDate].",".$startMoAry[1]);
$end_ts=strtotime($endMoAry[0]." ".$_GET[endDate].",".$endMoAry[1]);
// add 23hrs, 59 seconds, to make day end at 11:59pm, rather than 12am
$end_ts=$end_ts+86399;
include("session_tracker.inc.php");
/***************************************************
Connect to database
***************************************************/
include("mysql_access_db.php");
/***************************************************
Get oldest/newest record date from DB
***************************************************/
$query = "SELECT CalendarDate
FROM Calendar";
$result = mysql_query ($query);
while($row = mysql_fetch_assoc($result))
{
// convert to timestamp
$cal_date_timestamp = strtotime($row[CalendarDate]);
if(empty($oldest_record))
{
$oldest_record = strtotime($row[CalendarDate]);
}
if($cal_date_timestamp < $oldest_record)
{
$oldest_record = $cal_date_timestamp;
}
if(empty($newest_record))
{
$newest_record = strtotime($row[CalendarDate]);
}
if($cal_date_timestamp > $newest_record)
{
$newest_record = $cal_date_timestamp;
}
// build array of all values
$cal_date_timestamp_array[] = $cal_date_timestamp;
}
$cal_date_timestamp_array =array_unique($cal_date_timestamp_array);
sort($cal_date_timestamp_array);
// unique timestamps
foreach($cal_date_timestamp_array as $tk=>$tv)
{
// echo "$tk $tv<br>";
$cal_dt_ary[]= date ( "D, M d, Y", $tv);
$cal_moYr_ary[]= date ( "F Y", $tv);
$cal_mo_ary[]= date ( "F", $tv);
$cal_yr_ary[]= date ( "Y", $tv);
}
// unique full dates
$cal_dt_ary =array_unique($cal_dt_ary);
foreach($cal_dt_ary as $tk1=>$tv1)
{
// echo "$tk1 $tv1<br>";
}
// unique months
$cal_mo_ary =array_unique($cal_mo_ary);
foreach($cal_mo_ary as $tk2=>$tv2)
{
//echo "$tk2 $tv2<br>";
}
// unique years
$cal_yr_ary =array_unique($cal_yr_ary);
foreach($cal_yr_ary as $tk3=>$tv3)
{
//echo "$tk3 $tv3<br>";
}
// unique month/year combinations
$cal_moYr_ary = array_unique($cal_moYr_ary);
foreach($cal_moYr_ary as $tk4=>$tv4)
{
//echo "$tk4 $tv4<br>";
}
$oldest_record = array_shift($cal_date_timestamp_array);
$newest_record = array_pop($cal_date_timestamp_array);
// echo date ( "D, M d, Y", $newest_record);
/***************************************************
establish start of date range
If start_ts is not present, use oldest record in db as start date;
otherwise, use GET value for start date
***************************************************/
//$timestamp_minus30 = strtotime("-30 days");
if(empty($start_ts))
{
$timestamp_minus30 = $oldest_record;
}
elseif(!empty($start_ts))
{
$timestamp_minus30 = $start_ts;
}
/***************************************************
establish end of date range
***************************************************/
//$timestamp = time();
$timestamp = $newest_record;
//echo "Start date: ";
//$start_month_m=date ("m" , $oldest_record); // month as numeral with leading zero
if(empty($start_ts))
{
$start_month_m=date ("m" , $oldest_record); // month as numeral with leading zero
}
elseif(!empty($start_ts))
{
$start_month_m=date ("m" , $start_ts); // month as numeral with leading zero
}
$start_month_n=date ("n" , $oldest_record); // month as numeral without leading zero
$start_month_F=date ("F" , $oldest_record); // month as lonf text string (e.g. 'January')
$start_day_d=date ("d", $oldest_record);
$start_year_Y=date ("Y" , $oldest_record);
$end_month_m=date ("m" , $newest_record);
$end_month_n=date ("n" , $newest_record);
$end_month_F=date ("F" , $newest_record);
$end_day_d=date ("d", $newest_record);
$end_year_Y=date ("Y" , $newest_record);
// names of months
$month_array[]= "January";
$month_array[]= "February";
$month_array[]= "March";
$month_array[]= "April";
$month_array[]= "May";
$month_array[]= "June";
$month_array[]= "July";
$month_array[]= "August";
$month_array[]= "September";
$month_array[]= "October";
$month_array[]= "November";
$month_array[]= "December";
// START date
// February;check for leap year
if($start_month_m==2)
{
if(date("L",$newest_record) == 1)
{
$start_date_end = 29;
}
elseif(date("L",$newest_record) == 0)
{
$start_date_end = 28;
}
}
// months with 30 days
elseif($start_month_m==4 || $start_month_m==6 || $start_month_m==9 || $start_month_m==11)
{
$start_date_end = 30;
}
// months with 31 days
elseif($start_month_n==1 || $start_month_n==3 || $start_month_n==5 || $start_month_n==7 || $start_month_n==8 || $start_month_n==10 || $start_month_n==12)
{
$start_date_end = 31;
}
$start_date_begin = 1;
$end_date_begin = 1;
// END date
// February;check for leap year
if($end_month_n==2)
{
if(date("L",$newest_record) == 1)
{
$end_date_end = 29;
}
elseif(date("L",$newest_record) == 0)
{
$end_date_end = 28;
}
}
// months with 30 days
elseif($end_month_n==4 || $end_month_n==6 || $end_month_n==9 || $end_month_n==11)
{
$end_date_end = 30;
}
// months with 31 days
elseif($end_month_n==1 || $end_month_n==3 || $end_month_n==5 || $end_month_n==7 || $end_month_n==8 || $end_month_n==10 || $end_month_n==12)
{
$end_date_end = 31;
}
else
{
$end_date_end = "";
}
/***************************************************
Scrub user-submitted data
NOTE: Since it's a GET function ALL data can be submitted by the user
in the location window
***************************************************/
if($_GET)
{
while($_GET[searchInput] != strip_tags($_GET[searchInput]))
{
$_GET[searchInput] = strip_tags($_GET[searchInput]);
}
}
?>
<form name="formSearchMeetings" action="<?php echo $page_name; ?>" method="GET" >
<input type="hidden" name="v" value="<?php echo $_GET[v];?>">
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="meetingcaltable">
<tr>
<td colspan="9" align="left" valign="top"><span class="textHeadlines">
Appointments</span> from <?php echo $start_month_F . " " . $start_day_d . ", " . $start_year_Y . " to " . $end_month_F . " " . $end_day_d . ", " . $end_year_Y;?> .
</td>
</tr>
<?php
/***************************************************
Display 'Detail' search buttons ('New Search' and 'Previous Search')
***************************************************/
if(!empty($_GET[vtype]) && $_GET[vtype]=="detail")
{
include "display_detail_search.inc.php";
}
else
{
// determine which, if any, radio button is selected
if($_GET[search_type]=="") { $sel3="checked"; }
if($_GET[search_type]=="any") { $sel1="checked"; }
elseif($_GET[search_type]=="leader") { $sel2="checked"; }
elseif($_GET[search_type]=="meeting_num") { $sel3="checked"; }
elseif($_GET[search_type]=="party") { $sel4="checked"; }
elseif($_GET[search_type]=="short_title") { $sel5="checked"; }
?>
<tr class="odd">
<td colspan="9" align="left" valign="top">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top" nowrap><b>Search by: </b></td>
<td align="left" valign="top"><input type="radio" name="search_type" value="meeting_num" <?php echo $sel3;?>></td>
<td align="left" valign="top" nowrap><b> Reason Num.</b> </td>
<td align="left" valign="top"><input type="radio" name="search_type" value="short_title" <?php echo $sel5;?>></td>
<td align="left" valign="top" nowrap> Reason Name </td>
<td align="left" valign="top"><input type="radio" name="search_type" value="party" <?php echo $sel4;?>></td>
<td align="left" valign="top" nowrap> Party name </td>
<td align="left" valign="top"><input type="radio" name="search_type" value="atty" <?php echo $sel2;?>></td>
<td align="left" valign="top" nowrap> Responcibility </td>
<td align="left" valign="top" ><input type="radio" name="search_type" value="any" <?php echo $sel1;?>></td>
<td align="left" valign="top" nowrap> MeetingRoom/Date </td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="9" align="left" valign="top">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="LEFT" valign="top"><b>Search for: </b></td>
<td align="LEFT" valign="top"><input type="text" name="searchInput" <?php if(!empty($_GET[searchInput])) { echo "value =\"$_GET[searchInput]\""; } ?>size="27"></td>
<td align="left" valign="top"></td>
<td align="LEFT" valign="top"><input type="radio" name="search_scope" value="broad" <?php if($_GET[search_scope]=="broad" || $_GET[search_scope]=="") { echo "checked"; } ?>></td>
<td align="left" valign="top"> Single or partial word or number </td>
<td align="LEFT" valign="top"><input type="radio" name="search_scope" value="strict" <?php if($_GET[search_scope]=="strict") { echo "checked"; } ?>></td>
<td align="left" valign="top"> exact phrase </td>
</tr>
<tr>
<td align="LEFT" valign="top"></td>
<td colspan="6" align="LEFT" valign="top">(e.g. 12345 or SFL-12345; DOE or DOE, JOHN etc.)</td>
</tr>
</table>
</td>
</tr>
<tr class="odd">
<td colspan="9" align="left" valign="top">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right" valign="top"><b>By Meetingroom: </b></td>
<td align="right" valign="top"><?php
/***************************************************
query for Meetingroom menu
***************************************************/
buildCtrmMenu();
?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="9" align="left" valign="top">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top"><b>By Date: </b></td>
<td align="left" valign="top"><?php
/***************************************************
// START date select menu
***************************************************/
// if no month is selected, use default start
$i_begin_start_date = $start_date_begin;
$end_date_end=31; // set all months to have 31 days
// otherwise use selected month
echo "<select name=\"startDate\">";
// echo"<option value=\"\">Start Date</option>\n";
while(trim($i_begin_start_date) <= $end_date_end)
{
echo "<option value=\"$i_begin_start_date\"";
// match submitted end date, if any.
// make sure Get[endDate] is NOT empty; otherwise it'll use the default setting to select the date,
if(!empty($_GET[startDate]) && $_GET[startDate] == $i_begin_start_date)
{
echo " selected " ;
}
// default to selecting current day/date
elseif(empty($_GET[startDate]) && $start_day_d == $i_begin_start_date)
{
echo " selected " ;
}
// Do nothing...
else {}
if($i_begin_start_date==1 || $i_begin_start_date==21 || $i_begin_start_date==31) {
$dt_end="st";
}
elseif($i_begin_start_date==2 || $i_begin_start_date==22) {
$dt_end="nd";
}
elseif($i_begin_start_date==3 || $i_begin_start_date==23) {
$dt_end="rd";
}
elseif($i_begin_start_date>=4 && $i_begin_start_date <=20 || $i_begin_start_date>=24 && $i_begin_start_date<=30) {
$dt_end="th";
}
echo ">$i_begin_start_date$dt_end</option>\n";
$i_begin_start_date++;
}
echo "</select>\n";
?></td>
<td align="left" valign="top"> day of
<?php
$oldest_select = trim(date ( "F Y", $oldest_record));
echo "<select name=\"startMonth\">";
foreach($cal_moYr_ary as $tk4=>$tv4)
{
echo "<option value=\"$tv4\"";
if(!empty($_GET[startMonth]) && $_GET[startMonth] == $tv4)
{
echo " selected " ;
}
// default to selecting current day/date
elseif(empty($_GET[startMonth]) && $oldest_select == $tv4)
{
echo " selected " ;
}
echo ">$tv4</option>\n";
}
echo "</select>";
?></td>
<td align="left" valign="top"></td>
<td align="left" valign="top"> to the</td>
<td align="left" valign="top"><?php
/***************************************************
END DATE SELECT MENU
***************************************************/
$i_begin_ending_date = $start_date_begin;
$end_date_end=31; // set all months to 31 days
echo "<select name=\"endDate\">";
while(trim($i_begin_ending_date) <= $end_date_end)
{
echo "<option value=\"$i_begin_ending_date\"";
// match submitted end date, if any.
// make sure Get[endDate] is NOT empty; otherwise it'll use the default setting to select the date,
if(!empty($_GET[endDate]) && $_GET[endDate] == $i_begin_ending_date)
{
echo " selected " ;
}
// default to selecting current day/date
elseif(empty($_GET[endDate]) && $end_day_d == $i_begin_ending_date)
{
echo " selected " ;
}
// Do nothing...
else {}
if($i_begin_ending_date==1 || $i_begin_ending_date==21 || $i_begin_ending_date==31) {
$dt_end="st";
}
elseif($i_begin_ending_date==2 || $i_begin_ending_date==22) {
$dt_end="nd";
}
elseif($i_begin_ending_date==3 || $i_begin_ending_date==23) {
$dt_end="rd";
}
elseif($i_begin_ending_date>=4 && $i_begin_ending_date <=20 || $i_begin_ending_date>=24 && $i_begin_ending_date<=30) {
$dt_end="th";
}
echo ">$i_begin_ending_date$dt_end</option>\n";
$i_begin_ending_date++;
}
echo "</select>\n";
unset($error);
?></td>
<td align="left" valign="top"> day of</td>
<td align="left" valign="top">
<?php
$newest_select = trim(date ( "F Y", $newest_record));
echo "<select name=\"endMonth\">";
foreach($cal_moYr_ary as $tk4=>$tv4)
{
echo "<option value=\"$tv4\"";
if(!empty($_GET[endMonth]) && $_GET[endMonth] == $tv4)
{
echo " selected " ;
}
// default to selecting current day/date
elseif(empty($_GET[endMonth]) && $newest_select == $tv4)
{
echo " selected " ;
}
echo ">$tv4</option>\n";
}
echo "</select>";
?></td>
</tr>
</table>
</td>
</tr>
<tr class="odd">
<td colspan="9" align="left" valign="top">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top" nowrap></td>
<td align="left" valign="top" nowrap><input type="submit" name="submitMeeting" value="Search"> <span class="textSmall">See '<b>Search Tips</b>' in sidebar for help.</span></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="9" align="left" valign="top">
<?php
} // end if NOT detail view
/***************************************************
DETERMINE WHICH SEARCH TYPE HAS BEEN REQUESTED
http://domain.com/$page_name?v=meetings
&search_type=meeting_num
&dept_search_menu=
&startDate=11
&startMonth=January%202005&endDate=31
&endMonth=March%202005
&searchInput=SCV-232732
&search_scope=strict&
submitMeeting=Search
&vtype=detail
***************************************************/
if(!empty($_GET[vtype]) && $_GET[vtype]=="detail")
{
//echo "detail...";
include("meetings_detail.inc.php");
}
// if NOT detail view request...
elseif(empty($_GET[vtype]) || $_GET[vtype]!="detail")
{
//if(!empty($_GET[search_type]) && $_GET[vtype]!="detail")
if(!empty($_GET[search_type]) )
{
if($_GET[search_type]=="meeting_num")
{
// echo "search for meeting_num";
if(!empty($_GET[searchInput]))
{
include("meetingsqueryreasonnum.inc.php");
}
else {
echo "<b> ERROR. No Meeting Number entered. ";
}
}
elseif($_GET[search_type]=="short_title")
{
// echo "search for short_title";
if(!empty($_GET[searchInput]))
{
include("meetings_query_shorttitle.inc.php");
}
else {
echo "<b> ERROR. No Meeting Name entered. ";
}
}
elseif($_GET[search_type]=="atty")
{
if(!empty($_GET[searchInput]))
{
include("T_meetings_query_responsible.inc.php");
}
else
{
echo "<b> ERROR. No Meeting Leader Name entered. ";
}
}
elseif($_GET[search_type]=="party")
{
if(!empty($_GET[searchInput]))
{
include("meetings_query_party.inc.php");
}
else
{
echo "<b> ERROR. No Attendee Name entered. ";
}
}
elseif($_GET[search_type]=="any" && !empty($_GET[dept_search_menu]))
{
include("meetings_query_dept.inc.php");
}
elseif($_GET[search_type]=="any" && !empty($_GET[submitMeeting]) && empty($_GET[dept_search_menu]))
{
include("meetings_query_date.inc.php");
}
}
/***************************************************
Search by Meeting room only
***************************************************/
elseif(empty($_GET[search_type]) && !empty($_GET[dept_search_menu]))
{
include("meetings_query_dept.inc.php");
}
/***************************************************
Search by Date Range only
***************************************************/
elseif(!empty($_GET[submitMeeting]) && empty($_GET[search_type]) && empty($_GET[dept_search_menu]))
{
include("meetings_query_date.inc.php");
}
} // end if NOT detail view
?></td>
</tr>
</tr>
</table>
</form>
<?php
/***************************************************
FUNCTIONS
***************************************************/
/***************************************************
Build select menu for 'Courtrooms'
***************************************************/
function buildCtrmMenu()
{
// get list of active courtrooms from db
$queryDEPT = "SELECT *
FROM MeetingroomList
WHERE MeetingroomList.CtrmNameName != \"\"
";
$resultDEPT = mysql_query ($queryDEPT)
or die ("Cannot execute query.
<br>error message = " . mysql_error () . " from " . __FILE__ . " on line " . __LINE__);
if (mysql_num_rows ($resultDEPT) == 0)
{
echo ("No records found ");
}
echo "
<select name=\"dept_search_menu\">\n
<option value=\"\" $dsel>Any Meetingroom</option>\n";
while($rowDEPT = mysql_fetch_array($resultDEPT))
{
/***************************************************
Write select menu values
***************************************************/
// If matches selected menu value, mark as selected
$CtrmNameValue = $rowDEPT[CtrmNameValue];
if(trim($_GET[dept_search_menu]) == $CtrmNameValue)
{
$sel="selected";
}
else
{
$sel = "";
}
echo "
<option value=\"".$rowDEPT[CtrmNameValue]."\" $sel>".$rowDEPT[CtrmNameName]."</option>";
}
echo "
</select>";
}
/***************************************************
DISCLAIMER
***************************************************/
echo "<hr noshade size=\"1\">
<span class=\"textSmall\"><b>Please Note</b>: As the online calendars are
updated once daily, at 5 a.m., Monday-Friday, some current changes may not be available on-line until the 5 a.m. update.
If you are unable to find your meeting on-line, or need more information, please contact the Clerks in person, or by phone at xxx-xxx-xxxx.</span>";
/***************************************************
SEARCH TIPS
***************************************************/
echo "<br><br><span class=\"textSmall\"><b><a name=\"tips\">Search Tips:</a></b></br>
1) If you know the meeting number, use meeting number search for fastest results (e.g. SFL-12345 or 12345)<br>
2) If you know the meeting name, type in part of meeting name (e.g. JOHN)<br>
3) If you want to search by party's name or leaders's name:<br>
- Typically party/leader's name is entered as Lastname, Firstname (i.e. DOE, JOHN) and it is not case sensitive.<br>
- If you don't find your record, try typing DOE only or JOHN only and narrow the search results using the date range.</span><br>";
/***************************************************
If request is for 'detail' view, display note on how to see Calendar Type Abbr. explanation
***************************************************/
if($_GET[vtype]==detail)
{
echo "<span class=\"textSmall\">4) Hold mouse over 'CAL. TYPE' abbreviation for explanation.</span><br>";
}
/***************************************************
how long the report took to generate...
***************************************************/
$end_time = getmicrotime();
$report_seconds = "<br><span class=\"tinyText\">Meeting query completed in ". substr($end_time-$start_time,0,5)." seconds</span>\n";
echo "$report_seconds";
// display session variables
foreach($_SESSION as $ks=>$vs)
{
// echo "$ks $vs<br>";
}
/***************************************************
// Simple function for retrieving the current timestamp in microseconds
***************************************************/
function getmicrotime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
?>
Research
Things that are not the answer....
In doing other research, I found how to check the syntax of the files by using
php -l <filename>
. Trying this on both the common.inc and the php file for the body of the page resulted in"No syntax errors"
for each.
~
Why this is not answered by PHP Parse/Syntax Errors; and How to solve them?:
I looked at this article before I posted. Good article. Problem is that
the file in question was not just created, it worked just fine before.
Barring that I've looked as best I can and there are no missing or misplace syntax.
Include is not used anywhere in the file! While it is written in the comments and there are references to the includes directory, the instruction include IS NOT USED! And yes, I've checked to make sure that the comments are comments and an include is not sticking out somewhere.
~
Why this is not answered by T_INCLUDE - Issue :
Again include is not in the file as a command. Neither is DIR. All the semi-colons are there all the quotations are there. This file worked before the upgrade. This file works on pages where there is no PHP code. This answer does not answer my question.