Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Help altering if code inherited

    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();
    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) == 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

    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);

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,492
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •