Results 1 to 3 of 3

Thread: end of file doesnt complete...

  1. #1
    Join Date
    May 2008
    Posts
    144
    Thanks
    6
    Thanked 11 Times in 11 Posts

    Default end of file doesnt complete...

    ok, i have an index with a content include... with a certain content include, iit leaves off the close tags for body, html & a div tag as well as omitting another include for the footer...
    here is the index code:
    PHP Code:
    <?php
    session_start
    ();

    include(
    "../lib/login.php");
    login();
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Home Owning Resources | Admin</title>
    <link href="css/admin.css" rel="stylesheet" type="text/css">
    <link href="floatbox/floatbox.css" rel="stylesheet" type="text/css">
    <script language="javascript" type="text/javascript" src="floatbox/floatbox.js"></script>
    <script language="javascript" type="text/javascript" src="../js/mootools.js"></script>
    <script language="javascript" type="text/javascript" src="../js/admin.js"></script> 
    </head>
    <body>
    <?php
        
    include("inc/header.inc.php");
        echo 
    "<div id=\"mainbody\">\n";

        if (!isset(
    $_REQUEST['content']))
        {
            if (!isset(
    $_SESSION['admin']))
                include(
    "inc/login.inc.php");
            else
            {
                include(
    "inc/report.inc.php"); 
            }
        }
        else 
        { 
            if (!isset(
    $_SESSION['admin']))
                include(
    "inc/login.inc.php");
            else
            {
            
    $content "inc/" $_REQUEST['content'] . ".inc.php";
            include(
    $content);
            }
        }

        echo 
    "</div>\n";
        include(
    "inc/footer.inc.php");
        echo 
    "</body>\n";
        echo 
    "</html>\n";
    ?>
    and here is the include in question:
    PHP Code:
    <?php

        $action 
    $_REQUEST['action'];
        echo 
    "<h2>Edit Listing</h2>\n";
        if (
    $action == 'delete')
        {
            
    $id $_REQUEST['id'];
            
    $query "DELETE FROM listings WHERE id = $id";
            
    $result mysql_query($query) or die(mysql_error());
                if (
    $result)
                {
                echo 
    "You have successfully deleted that listing.<br>\n";
                echo 
    "<a href=\"index.php?content=listings\">Return to Listings</a>\n";
                exit;
                } else
                {
                echo 
    "Sorry, there was a problem deleting that listing.<br>\n";
                echo 
    "<a href=\"index.php?content=listings\">Return to Listings</a>\n";
                exit;
                }
            exit;
        }
        else if(
    $action == 'add')
        {
            
    $name $_POST['name'];
            
    $phone $_POST['phone'];
            
    $address $_POST['address'];
            
    $type $_POST['type'];
            if (
    get_magic_quotes_gpc())
            {
                
    $name stripslashes($name);
                
    $phone stripslashes($phone);
                
    $address stripslashes($address);
                
    $type stripslashes($type);
            }
            
    $name mysql_real_escape_string($name);
            
    $phone mysql_real_escape_string($phone);
            
    $address mysql_real_escape_string($address);
            
    $type mysql_real_escape_string($type);
            if (isset(
    $_POST['featured']))
                
    $featured 1;
            else
                
    $featured 0;
            if (isset(
    $_POST['active']))
                
    $display 1;
            else
                
    $display 0;
            
    $areaid $_POST['area'];
            
    $areaquery "SELECT city, state, zip FROM area WHERE id=$areaid";
            
    $arearesult mysql_query($areaquery) or die(mysql_error());
            
    $arearow mysql_fetch_array($arearesultMYSQL_ASSOC);
                
    $areacity $arearow['city'];
                
    $areastate $arearow['state'];
                
    $areazip $arearow['zip'];
            
    $city $areacity ", " $areastate " " $areazip;
            
    $zip $areazip " (" $areacity ", " $areastate ")";
            
    $nearids $_POST['nareas'];
            
    $nearquery implode("' OR id = '"$nearids);
            
    $areaquery "SELECT id, city, state, zip FROM area WHERE id='$nearquery'";
            
    $arearesult mysql_query($areaquery) or die(mysql_error());
            
    $i 0;
            while(
    $arearow mysql_fetch_array($arearesultMYSQL_ASSOC)){
                
    $areacity $arearow['city'];
                
    $areastate $arearow['state'];
                
    $areazip $arearow['zip'];
                
    $nearcityarray[$i] = $areacity ", " $areastate " " $areazip;
                
    $nearziparray[$i] = $areazip " (" $areacity ", " $areastate ")";
                
    $i++;
            }
            
    $nearcity implode(";"$nearcityarray);
            
    $nearzip implode(";"$nearziparray);
            
    $nearidimplode implode(";"$nearids);
            
    $query "INSERT INTO listings (name, phone, address, type, featured, display, areaid, nearids, city, nearcity, zip, nearzip) VALUES ('$name', '$phone', '$address', '$type', '$featured', '$display', '$areaid', '$nearidimplode' ,'$city', '$nearcity', '$zip', '$nearzip')";
            
    $result mysql_query($query) or die(mysql_error());
                if (
    $result)
                {
                echo 
    "You have successfully added '" stripslashes($name) . ".'<br>\n";
                echo 
    "<a href=\"index.php?content=listings\">Return to Listings</a>\n";
                exit;
                } else
                {
                echo 
    "Sorry, there was a problem adding '" stripslashes($name) . ".'<br>\n";
                echo 
    "<a href=\"index.php?content=listings\">Return to Listings</a>\n";
                exit;
                }
            exit;
        }
        else if(
    $action == 'update')
        {
            
    $id $_REQUEST['id'];
            
    $name $_POST['name'];
            
    $phone $_POST['phone'];
            
    $address $_POST['address'];
            
    $type $_POST['type'];
            if (
    get_magic_quotes_gpc())
            {
                
    $name stripslashes($name);
                
    $phone stripslashes($phone);
                
    $address stripslashes($address);
                
    $type stripslashes($type);
            }
            
    $name mysql_real_escape_string($name);
            
    $phone mysql_real_escape_string($phone);
            
    $address mysql_real_escape_string($address);
            
    $type mysql_real_escape_string($type);
            if (isset(
    $_POST['featured']))
                
    $featured 1;
            else
                
    $featured 0;
            if (isset(
    $_POST['active']))
                
    $display 1;
            else
                
    $display 0;
            
    $areaid $_POST['area'];
            
    $areaquery "SELECT city, state, zip FROM area WHERE id=$areaid";
            
    $arearesult mysql_query($areaquery) or die(mysql_error());
            
    $arearow mysql_fetch_array($arearesultMYSQL_ASSOC);
                
    $areacity $arearow['city'];
                
    $areastate $arearow['state'];
                
    $areazip $arearow['zip'];
            
    $city $areacity ", " $areastate " " $areazip;
            
    $zip $areazip " (" $areacity ", " $areastate ")";
            
    $nearids $_POST['nareas'];
            
    $nearquery implode("' OR id = '"$nearids);
            
    $areaquery "SELECT id, city, state, zip FROM area WHERE id='$nearquery'";
            
    $arearesult mysql_query($areaquery) or die(mysql_error());
            
    $i 0;
            while(
    $arearow mysql_fetch_array($arearesultMYSQL_ASSOC)){
                
    $areacity $arearow['city'];
                
    $areastate $arearow['state'];
                
    $areazip $arearow['zip'];
                
    $nearcityarray[$i] = $areacity ", " $areastate " " $areazip;
                
    $nearziparray[$i] = $areazip " (" $areacity ", " $areastate ")";
                
    $i++;
            }
            
    $nearcity implode(";"$nearcityarray);
            
    $nearzip implode(";"$nearziparray);
            
    $nearidimplode implode(";"$nearids);
            
    $query "UPDATE listings SET name='$name', phone='$phone', address='$address', type='$type', featured='$featured', display='$display', areaid='$areaid', nearids='$nearidimplode', city='$city', nearcity='$nearcity', zip='$zip', nearzip='$nearzip' WHERE id = $id";
            
    $result mysql_query($query) or die(mysql_error());
                if (
    $result)
                {
                echo 
    "You have successfully updated '" stripslashes($name) . ".'<br>\n";
                echo 
    "<a href=\"index.php?content=listings\">Return to Listings</a>\n";
                exit;
                } else
                {
                echo 
    "Sorry, there was a problem updating '" stripslashes($name) . ".'<br>\n";
                echo 
    "<a href=\"index.php?content=listings\">Return to Listings</a>\n";
                exit;
                }
            exit;
        }
    ?>
    thanks in advance!

  2. #2
    Join Date
    May 2008
    Posts
    144
    Thanks
    6
    Thanked 11 Times in 11 Posts

    Default

    got it

  3. #3
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Hitting one of the exits too early?

    I think if you put

    PHP Code:
     ?>
    </div>
    <?php  include("inc/footer.inc.php"); ?>
    </body>
    </html>
    outside of the php you wont have to worry about that

Bookmarks

Posting Permissions

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