...

View Full Version : Help altering if code inherited



scorn
02-24-2012, 09:17 PM
Hi,
I do not know php at all and have inherited several websites that were created by someone else. I need to alter a piece of it and am not having any luck. My screen goes white. I think my issue is that I am trying to use the same criteria in two back to back if statments, but I don't know how to get a substring in the initial if clause.
The code is separating a nine digit number that relates to where a student's school area is. First 3 are Elementary, 2nd 3 are middle school etc.
We have combined schools and now I have to split out regions into two regions with each 'if' grouping. Each part works separately but not together.

I am going to list the two if statments below. Can anyone help me either combine them or get the Mad face code into the confused face code or tell me what else I need to do?

connectToDatabase();
:confused:if ($row['grade'] > 4 && $row['grade'] < 8 ) {
/*This begins the Middle School Choice Exceptions for East Forsyth MS and Philo-Hill MS including the EA, SE & SWG exceptions to the Residential Zones in the Schools table*/
:mad: if (substr($row['catchment'], 3, 3) == 366)
{if (substr($row['catchment'], 0, 6) == 376366 || substr($row['catchment'], 0, 6) == 390366 || substr($row['catchment'], 0, 6) == 508366)
{
// zone = SE
$override_zone = "SE";
$res_zone = "SE";
}
if (substr($row['catchment'], 0, 6) == 334366 || substr($row['catchment'], 0, 6) == 447366 || substr($row['catchment'], 0, 6) == 490366)
{
// zone = EA
$override_zone = "EA";
$res_zone = "EA";
}

}

else {
$searchable = substr($row['catchment'], 3, 3);
$res_query = mysql_query("SELECT zone from schools WHERE short_number = '$searchable'");
$res_row = mysql_fetch_row($res_query);
$res_zone = $res_row[0];
}
} else {

$res_query = "";
}


//closing schools database connection
mysql_close($link);
?>
<?php
:cool:
connectToDatabase();
if ($row['grade'] > 4 && $row['grade'] < 8) {
/*This begins the Middle School Choice Exceptions for East Forsyth MS and Philo-Hill MS including the EA, SE & SWG exceptions to the Residential Zones in the Schools table*/
if (substr($row['catchment'], 3, 3) == 492)
{if (substr($row['catchment'], 0, 6) == 376492 || substr($row['catchment'], 0, 6) == 390492)
{
// zone = SE
$override_zone = "SE";
$res_zone = "SE";
} else if (substr($row['catchment'], 0, 6) == 350492)
{
// zone = SW (green)
$override_zone = "SW (green)";
$res_zone = "SW (green)";
}
}

else {
$searchable = substr($row['catchment'], 3, 3);
$res_query = mysql_query("SELECT zone from schools WHERE short_number = '$searchable'");
$res_row = mysql_fetch_row($res_query);
$res_zone = $res_row[0];
}
} else {

$res_query = "";
}
//closing schools database connection
mysql_close($link);

mlseim
02-24-2012, 09:50 PM
White screen is an error with error reporting turned off.
Turn on PHP error reporting so you get a nice message about what is wrong and which line.

Google: PHP error reporting



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum