PHP5.5 And Apache2.4.7 Upgrade Problems »  Show posts from    to     

Icy Phoenix


Old Support Topics - PHP5.5 And Apache2.4.7 Upgrade Problems



AndyGpy [ Wed 22 Jan, 2014 00:24 ]
Post subject: PHP5.5 And Apache2.4.7 Upgrade Problems
Right Guys i have created a standard page

Code: [Hide] [Select]
<?php
/***************************************************************************
* Alertz.php
* -------------------
* begin : 30/10/04/10
* copyright : (C) 2010 Andy Guppy
* email : webmaster@scotbird.co.uk
*
*
***************************************************************************/
define('IN_ICYPHOENIX', true);
if (!defined('IP_ROOT_PATH')) define('IP_ROOT_PATH', './');
if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));

// Include files
include(IP_ROOT_PATH . 'common.' . PHP_EXT);
include(IP_ROOT_PATH . '/alerts/alertsconfig.'.PHP_EXT);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// End session management


$meta_content['page_title'] = 'Scotbird Alertz System';
$meta_content['description'] = 'Rare and Unusual sightings throughout Scotland';
$meta_content['keywords'] = '';

if (!$user->data['session_logged_in'])

{

redirect(append_sid(CMS_PAGE_LOGIN . '?redirect=alertz_VIP.' . PHP_EXT, true));
exit;
}

else
// Yes they are
{

// Obtain Select Criteria
$temp_region_filter = $_GET["REGION_FILTER"];
$temp_species_filter = $_GET["SPECIES_FILTER"];
$temp_date_filter = $_GET["DATE_FILTER"];

// Filter characters if required
$region_filter =str_replace(" & ", "&", $temp_region_filter);
$species_filter = $temp_species_filter;
$date_filter = $temp_date_filter;

// Connect to the database
$db = new sql_db($alerts_mysql_host,$alerts_mysql_username,$alerts_mysql_password,$alerts_mysql_db,false);
if(!$db)
{
die("Database Connection Failed:- Please Contact Site Admin" . mysql_error());
}
//$template->set_filenames(array('body' => 'alertz_VIP.tpl'));
//$template->_tpldata['alertz_VIP.'] = array();
// Some consistant Variables
$year =date("Y");
$month = date("m");
$day = date("d");

function datedropdown_funct($switchstring)
{
$year =date("Y");
$month = date("m");
$day = date("d");
switch ($switchstring)
{

case "Today":
$day = date("d");
$retval = '<option value="">Select</option><option value="Today" SELECTED>Today</option><option value="Last 48hrs">Last 48hrs</option><option value="Last week">Last Week</option><option value="last month">Last Month</option>';
break;
case "Last 48hrs":
$day = date("d")-1;
$retval = '<option value="">Select</option><option value="Today">Today</option><option value="Last 48hrs" SELECTED>Last 48hrs</option><option value="Last week">Last Week</option><option value="last month">Last Month</option>';
break;
case "Last week":
$day = date("d")-7;
$retval = '<option value="">Select</option><option value="Today">Today</option><option value="Last 48hrs">Last 48hrs</option><option value="Last week" SELECTED>Last Week</option><option value="last month">Last Month</option>';
break;
case "last month":
$month = date("m")-1;
$retval = '<option value="">Select</option><option value="Today">Today</option><option value="Last 48hrs">Last 48hrs</option><option value="Last week">Last Week</option><option value="last month" SELECTED>Last Month</option>';
break;
case "last 3 months":
$month = date("m")-3;
$retval = '<option value="">Select</option><option value="Today">Today</option><option value="Last 48hrs">Last 48hrs</option><option value="Last week">Last Week</option><option value="last month">Last Month</option><option value="last 3 months" SELECTED>Last 3 Month</option>';
break;
default:
// Default is the last 48hrs
$day = date("d")-3;

}
$thestartdatecalc = $year . '-' .$month . '-' . $day ;
// echo $thestartdate;
return array($retval, $thestartdatecalc);
}


$theenddate = $year . '-' .$month . '-' . $day ;

// Check if the Date is Set
if(isset($date_filter) and strlen($date_filter) > 0)
{
// The date is Set
// echo "Date is Set :- " . $date_filter . " - ";
// Check to see if Region is set
if(isset($region_filter) and strlen($region_filter) > 0)
{
// The region is set
// echo "Region is Set :- " . $region_filter . " - ";
// Check to see if species is set
if(isset($species_filter) and strlen($species_filter) > 0)
{
// The species is set
// echo "Species is Set :- " . $species_filter . " - ";
list($arr1, $arr2) = datedropdown_funct($date_filter);
$date_filter_options= $arr1;
$thestartdate.= $arr2;
$sql2 = "SELECT * FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' AND region = '".$region_filter ."' AND species = '".$species_filter ."' ORDER BY Date DESC, time DESC ";
$sql3 = "SELECT DISTINCT species FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' AND region = '". $region_filter . "' GROUP BY species";
$sql = "SELECT DISTINCT region FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' AND species = '".$species_filter ."' GROUP BY region";

}
else
{
// The species is Not Set
// echo "Species is NOT set - ";
list($arr1, $arr2) = datedropdown_funct($date_filter);
$date_filter_options= $arr1;
$thestartdate.= $arr2;
$sql2 = "SELECT * FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' AND region = '".$region_filter ."' ORDER BY Date DESC, time DESC ";
$sql3 = "SELECT DISTINCT species FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' AND region = '". $region_filter . "' GROUP BY species";
$sql = "SELECT DISTINCT region FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' GROUP BY region";


}
}
else
{
// The region is not set
// echo "Region is NOT set - ";
// Check to see if species is set
if(isset($species_filter) and strlen($species_filter) > 0)
{
// The species is set
// echo "Species is Set :- " . $species_filter . " - ";
list($arr1, $arr2) = datedropdown_funct($date_filter);
$date_filter_options= $arr1;
$thestartdate.= $arr2;
$sql2 = "SELECT * FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' AND species = '".$species_filter ."' ORDER BY Date DESC, time DESC ";
$sql3 = "SELECT DISTINCT species FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' GROUP BY species";
$sql = "SELECT DISTINCT region FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' AND species = '".$species_filter ."' GROUP BY region";
}
else
{
// The species is NOT Set
// echo "Species is NOT set - ";
list($arr1, $arr2) = datedropdown_funct($date_filter);
$date_filter_options= $arr1;
$thestartdate.= $arr2;
$sql2 = "SELECT * FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' ORDER BY Date DESC, time DESC ";
$sql3 = "SELECT DISTINCT species FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' GROUP BY species";
$sql = "SELECT DISTINCT region FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' GROUP BY region";
}
}
}
else
{
// The date is not set
$date_filter_options = '<option value="">Select</option><option value="Today">Today</option><option value="Last 48hrs">Last 48hrs</option><option value="Last week">Last Week</option><option value="last month">Last Month</option>';
// echo "Date is NOT set - ";
// Check to see if Region is set
if(isset($region_filter) and strlen($region_filter) > 0)
{
// The region is set
// echo "Region is Set :- " . $region_filter . " - ";
// Check to see if species is set
if(isset($species_filter) and strlen($species_filter) > 0)
{
// The species is Set
// echo "Species is Set :- " . $species_filter . " - ";
// Build the SQL strings
$sql2 = "SELECT * FROM alerts WHERE species ='".$species_filter ."' AND region = '".$region_filter ."' ORDER BY Date DESC, time DESC ";
$sql = "SELECT DISTINCT region FROM alerts WHERE species ='".$species_filter ."' GROUP BY region";
$sql3 = "SELECT DISTINCT species FROM alerts WHERE region ='".$region_filter ."' GROUP BY species";
//

}
else
{
// The species is not set
// echo "Species is NOT set - ";
$sql2 = "SELECT * FROM alerts WHERE region = '".$region_filter ."' ORDER BY Date DESC, time DESC ";
$sql = "SELECT DISTINCT region FROM alerts WHERE species ='".$species_filter ."' GROUP BY region";
$sql3 = "SELECT DISTINCT species FROM alerts WHERE region ='".$region_filter ."' GROUP BY species";
}

}
else
{
// The region is Set
// echo "Region is NOT set - ";
// Check to see if species is set
if(isset($species_filter) and strlen($species_filter) > 0)
{
// The species is Set
// echo "Species is Set :- " . $species_filter . " - " ;

// Build the SQL strings
$sql2 = "SELECT * FROM alerts WHERE species ='".$species_filter ."' ORDER BY Date DESC, time DESC ";
$sql = "SELECT DISTINCT region FROM alerts GROUP BY region";
$sql3 = "SELECT DISTINCT species FROM alerts WHERE species ='".$species_filter ."' GROUP BY species";
//



}
else
{
// The species is not set
// echo "Species is NOT set - ";

// We will only display 5 days worth of Data
$year =date("Y");
$month = date("m");
$day = date("d")-3;
$thestartdate = $year . '-' .$month . '-' . $day ;
// Build the SQL strings
$sql2 = "SELECT * FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' ORDER BY Date DESC, time DESC ";
$sql3 = "SELECT DISTINCT species FROM alerts GROUP BY species";
$sql = "SELECT DISTINCT region FROM alerts GROUP BY region";
}
}
}


$result2 = $db->sql_query($sql2);
if (!($result2 = $db->sql_query($sql2)))
{
die("Database Query Failed" . mysql_error());
}
$i = 1;

while ( $row2 = $db->sql_fetchrow($result2) )
{
//if (($userdata['user_rank2'] == 5))
//{
$template->assign_block_vars('alerts', array( 'POS' => $i ,
'REGION' => str_replace("&", " & ", $row2['region']),
'SPECIES' => str_replace("%", "'",$row2['species']),
'DATE' => $row2['Date'],
'TIME' => $row2['time'],
'COMMENTS' => str_replace("'", "%",$row2['comments']),
)
);
$i++;
//}
//else
//{
// $template->assign_block_vars('alerts', array( 'POS' => $i ,
// 'REGION' => "VIP MEMBERS ONLY",
// 'SPECIES' => str_replace("%", "'",$row2['species']),
// 'DATE' => $row2['Date'],
// 'TIME' => $row2['time'],
// 'COMMENTS' => "Become a VIP and get full access",
// )
// );
//$i++;
//}
}

$template->assign_vars(array(
'USERNAME' => htmlspecialchars($user->data[username]),
'REGION_FILTER' => str_replace("&", " & ", $region_filter_options),
'SPECIES_FILTER' => $species_filter_options,
)
);

$result = $db->sql_query($sql2);

if (!($result = $db->sql_query($sql2)))
{
die("Database Query Failed" . mysql_error());
}

// This is where you would add a new VARS Array if you intend to use your own custom VARS.


while ($row = $db->sql_fetchrow($result))
{
$selected = (isset($_GET['REGION_FILTER']) AND $_GET['REGION_FILTER']==$row['region']) ? ' selected="selected"' : '' ;
$region_filter_options .= "<option value=\"{$row['region']}\"{$selected}>{$row['region']}</option>\n";
}



$result = $db->sql_query($sql3);

if (!($result = $db->sql_query($sql3)))
{
die("Database Query Failed" . mysql_error());
}

// This is where you would add a new VARS Array if you intend to use your own custom VARS.
while ($row = $db->sql_fetchrow($result))
{
$selected = (isset($_GET['SPECIES_FILTER']) AND $_GET['SPECIES_FILTER']==$row['species']) ? ' selected="selected"' : '' ;
$species_filter_options .= "<option value=\"{$row['species']}\"{$selected}>{$row['species']}</option>\n";
}



$template->assign_vars(array(
'USERNAME' => htmlspecialchars($user->data[username]),
'REGION_FILTER' => str_replace("&", " & ", $region_filter_options),
'SPECIES_FILTER' => $species_filter_options,

)
);


$template->assign_vars(array(
'USERNAME' => htmlspecialchars($user->data[username]),
'DATE_FILTER' => $date_filter_options,
)
);

// Build the page
//$template->pparse('body');



}
//full_page_generation();
full_page_generation('alertz_VIP.tpl', '', '', '');
?>


Before upgrading from Apache 2.2 to 2.2.4.7 and PHP 5.3 to 5.5, this page worked a treat. Now i get nothing from the databases, after puting in a small echo to display the out the username of the database

echo "DB Username is :- " . $alerts_mysql_username

which is passed in the

include(IP_ROOT_PATH . '/alerts/alertsconfig.'.PHP_EXT);

as a variable called

$alerts_mysql_username

the name is not displayed, if i set the variables in the above code for the database configuration the program will work, but i would like to remain as original code was ie call a database config file "alertsconfig.php".

Any suggestions as to why this will no longer work, i have tried it in IP 2.0 and also the same statement in IP1.53, i know no support is given for IP1.53, but my reference to it is so that you guys know that it does not just affect IP2.0 specifically.

I am a newbie when it comes to PHP settings and feel there must ne something fundamental i am missing.


when run nothing is displayed by the echo command,


mort [ Wed 22 Jan, 2014 03:08 ]
Post subject: Re: PHP5.5 And Apache2.4.7 Upgrade Problems
You are trying to use "echo" in a php file that is NOT a php template. In other words the .php file is running in the background and parsing the information to the .tpl file.

You would no doubt have to define what you are trying to echo and add the DEFINED CONSTANT(s) or Defined $variable(s) you use to the .tpl file.

This is an example of how "echo" is used when combined in common with the php script when the template is part of the same page.
Spoiler: [ Show ]



And PLEASE use the SPOILER when you post heaps of code.


AndyGpy [ Wed 22 Jan, 2014 08:12 ]
Post subject: Re: PHP5.5 And Apache2.4.7 Upgrade Problems
Mort

You are missing the point here, the echo command is not the problem, the problem is the variables i have stored in alertsconfig.php are not being included.

include(IP_ROOT_PATH . '/alerts/alertsconfig.'.PHP_EXT);

The echo command serves its purpose during a fault on the page, the ones that are there after // are only comments and parts of old code that will be removed.

if i copy and paste the contents of alertsconfig.php into the code above the full page works. if i dont copy the variable in the page fails with a sql error of

SQL ERROR [ mysql4 ]

[0]

BACKTRACE

FILE: includes/db/mysql.php
LINE: 111
CALL: sql_db->sql_error()

FILE: alertz_VIP.php
LINE: 53
CALL: sql_db->sql_db()

if i replace the

include(IP_ROOT_PATH . '/alerts/alertsconfig.'.PHP_EXT);

with

$alerts_mysql_username = "username"; // MySQL user name
$alerts_mysql_password = "password"; // MySQL password (leave empty
$alerts_mysql_db = "scotbirdalerts"; // MySQL database name
$alerts_mysql_host = "localhost"; // MySQL server host name

then it works.

regards


mort [ Wed 22 Jan, 2014 12:08 ]
Post subject: Re: PHP5.5 And Apache2.4.7 Upgrade Problems
Methinks you have one too many forward slashes here ->

include(IP_ROOT_PATH . '/alerts/alertsconfig.'.PHP_EXT);

so your path would be translating to www.blah//alerts/alertsconfig.php?


See what I mean - The initial or ROOT Directory paths don't have a forward slash because it's automatically added by IP_ROOT_PATH Constant?

include(IP_ROOT_PATH . 'includes/ajax_shoutbox_inc.' . PHP_EXT);


AndyGpy [ Wed 22 Jan, 2014 15:42 ]
Post subject: Re: PHP5.5 And Apache2.4.7 Upgrade Problems
Have tried that Mort and it is still the same.


Later in Evening --

Hi Mort / MG

Figured it out guys, my alertsconfig file contained

<?

some code

?>

but i believe PHP 5.5.6 has tighter rules and it must be

<?PHP

some code

?>

but all fixed and working.

I may have another topic for you shortly , what this space

MORT -- thanks for helping my friend , can you please mark as SOLVED


mort [ Wed 22 Jan, 2014 23:52 ]
Post subject: Re: PHP5.5 And Apache2.4.7 Upgrade Problems
From memory - php.ini can be configured to cater for short tags <? and long tags <?php as well

Though long tags <?php is generally the norm since php5* else the page just turns into garble.

And NO! I can't mark it solved but YOU can - - when you scroll below the post - on the right-hand side.


AndyGpy [ Thu 23 Jan, 2014 01:18 ]
Post subject: Re: PHP5.5 And Apache2.4.7 Upgrade Problems
I must be blind as well as thick Mort, i cannot see what you are refering to for solved, i have wend down bottom of page and cant see it


mort [ Thu 23 Jan, 2014 04:22 ]
Post subject: Re: PHP5.5 And Apache2.4.7 Upgrade Problems
You're right,

I just had a look at some of the posts I initiated as the "Thread Starter / Owner" and can't see anything either?

There used to be an option box with Solved and a couple of other options that would tag the Title as solved etc?

What's happened to it I have no idea - Maybe it's been set for moderators only?

So the only other way - Short Term - would be to edit the first post and add [Solved] to the title.


Informpro [ Fri 24 Jan, 2014 20:12 ]
Post subject: Re: [ SOLVED ] -- PHP5.5 And Apache2.4.7 Upgrade Problems
I think it's just tagged in the title :P.




Powered by Icy Phoenix