Results 1 to 7 of 7
Thread: echo " "; fixes evaluation error
-
March 28th, 2005, 03:01 PM #172Registered User
postsecho " "; fixes evaluation error
For some reason, I have an if statement that is evaluating incorrectly. Wierd thing is, if I put an echo " "; or a die (" "); anywhere in the script, it evaluates correctly and the script works perfectly. Does anybody know why the heck this is? Thanks
[swf="http://www.captainclyde.net/temp/sig.swf height=60 width=300"][/swf]
-
March 29th, 2005, 02:55 AM #2
can you post an example?
--------------------------------------------
Sign here plz.
-
March 29th, 2005, 01:35 PM #372Registered User
postsThis is the script that is experiencing the problems. I've never seen this happen before.
PHP Code:<?php
// Mod Index Page
// Written by John French
// mod_index.php
//
// Primary index page for mod_user
// Define the security control variable, IN_MOD.
define("IN_MOD", 1);
//
// Include the common includes
// This include initializes the following objects
//
// $db = the database abstraction objct
// $error = the error reporting object
// $validator = the validation object
//
require_once "../mod_shared/mod_common.inc.php";
//
// include the layout of the site's pages
//
require_once "mod_page_params.inc.php";
//--------------------------------------------Begin processing the page--------------------------------
//
// First, we process the variables sent to the page via the rewritten URL.
// They come in the form www.site.com/page_var/variables (delimited by / )
//
if(isset($_GET['page']) && !empty($_GET['page']))
{
if(!$v_page = $validator->validate_alphanumeric($_GET['page']))
{
// If page name is invalid, die with a 404
$error->die_report("page_not_found", __LINE__, __FILE__);
}
}
else
{
$v_page = "index";
}
//
// Now we process the variables sent with the URL
//
$_ARGS = array();
if(isset($_GET['args']) && !empty($_GET['args']))
{
// trim the annoying slash off of the end of the string
$query_str = rtrim($_GET['args'], "/");
// break the query into variables stored into an array
$_ARGS = explode("/", $query_str);
}
// check to see if our $v_page is in the site page array. if it's not, then we check the mod page arr
if(array_key_exists($v_page, $site_page_arr))
{
$page_specs_arr = $site_page_arr[$v_page];
}
else if (array_key_exists($v_page, $mod_page_arr))
{
$page_specs_arr = $mod_page_arr[$v_page];
}
else
{
$error->die_report("page_not_found", __LINE__, __FILE__);
}
//static
if($page_specs_arr[0] == 0)
{
$template->set_template($page_specs_arr[1]);
if(!$xhtml_main = $template->parse_template())
{
// if you put an echo " "; here, this conditional will evaluate correctly. If not, it evaluates to true.
$error->die_report("template_failed", __LINE__, __FILE__);
}
}
else
{
// dynamic page compiles and returns xhtml
$page_inc = $page_specs_arr[1];
$xhtml_main = include($page_inc);
}
//
// Check to see if the page we are loading requires a
// template other than the default
//
if(isset($page_specs_arr[2]) && file_exists($page_specs_arr[2]))
{
// if key exists, set the xhtml_template to it's value
$xhtml_template = $page_specs_arr[2];
}
else
{
// Use the main template
$xhtml_template = "../site_templates/xhtml_main.htm";
}
//
//----------------------------------------------Site-specific Includes (editable)------------------------------------------
// Some sites will requre multiple script includes for various bits of dynamic content in other parts of
// the page that aren't the main body generated by the include script.
//---------------------------------------------------------------------------------------------------------------
//
// Include pages that appear on the site that aren't the main content
//
// Include the upcoming shows script
$xhtml_nav_2 = "Upcoming Show: Sat Mar 22 11:00 PM Headhunter's"; //include("mod_nextshow.php");
// Include the photos script
$xhtml_main_2 = "View Photo"; //include("mod_viewphoto.php");
// Include the separate photo thumbnail script
$xhtml_sub_2 = "Thumbnails"; //include("mod_viewthumbs.php");
// Include the banner viewing script
$xhtml_sub_1 = include("mod_userlogin.php");
// Define the template variables and what they will be replaced by
$xhtml_main_replacements = array(
"{xhtml_head_1}" => $xhtml_head_1,
"{xhtml_nav_2}" => $xhtml_nav_2,
"{xhtml_sub_1}" => $xhtml_sub_1,
"{xhtml_sub_2}" => $xhtml_sub_2,
"{xhtml_main}" => $xhtml_main,
"{xhtml_main_2}" => $xhtml_main_2
);
//---------------------------------------------- End site-specific includes-----------------------------------
// ---------------------------------------------- Begin template formatting-----------------------------------
//
//
$template->set_template($xhtml_template);
if(!$xhtml_output = $template->parse_template($xhtml_main_replacements))
{
// Since this is the main template formatter, we can't generate a formatted error_doc
// Therefore, we must DIE
die("Primary template engine failure.<br /><b>Line: </b>" . __LINE__ . "<br /><b>File: </b>" . __FILE__);
}
// Template successfully parsed. Output valid XHTML.
echo $xhtml_output;
?>[swf="http://www.captainclyde.net/temp/sig.swf height=60 width=300"][/swf]
-
March 30th, 2005, 01:59 PM #4227Registered User
postsWhich part of that do you think evaluates incorrectly?
Generally speaking, anything 'fixed' by an 'echo' or 'die' was broken in the first place. Fix the heart of the problem, the workaround using echo or die is just hiding something (probably by sending output before the error generates a header() call).
-
March 30th, 2005, 02:21 PM #572Registered User
postsI didn't put it in there to fix a problem. Initially, I was using the dieto try to debug the script. When I put it in there, the script executed fine AND completely ignored the die(). The part that is evaluating incorrectly is
Originally Posted by JustJeff
I've thoroughly investigated all of my scripts. No errors.PHP Code:else
{
die("shoud be dying here");
$error->die_report("page_not_found", __LINE__, __FILE__);
}
[swf="http://www.captainclyde.net/temp/sig.swf height=60 width=300"][/swf]
-
March 30th, 2005, 03:45 PM #6227Registered User
postsThere's no way the die() is changing the way the if() {} elseif() {} else is evaluating - it's hiding something.
If it were me, I'd be using print_r() to show all of those variables, because something isn't happening the way you expect.
-
March 30th, 2005, 06:20 PM #772Registered User
posts
Originally Posted by JustJeff
I absolutely agree, I was just looking for a place to start in the process of debugging. I never entertained the idea of leaving the echo or die() in there as a hack. I'll try some stuff with print_r and see where it gets me. Thanks
John[swf="http://www.captainclyde.net/temp/sig.swf height=60 width=300"][/swf]
Similar Threads
-
Paste whatever is on your clipboard.
By GreenLantern in forum RandomReplies: 902Last Post: May 8th, 2013, 03:09 AM -
SQL syntax error
By SilentMind in forum Server-Side (PHP, SQL, ASP.NET, etc.)Replies: 1Last Post: October 6th, 2004, 11:30 AM -
MediaPlayBack Compontent + LoadMovieNum = Script Error!
By LFoz in forum Flash IDEReplies: 0Last Post: May 19th, 2004, 11:36 PM -
Parse error
By illusions in forum Server-Side (PHP, SQL, ASP.NET, etc.)Replies: 8Last Post: February 28th, 2003, 06:04 PM -
false loop error!
By waffe in forum ActionScript 2 (and Earlier)Replies: 2Last Post: November 26th, 2002, 09:56 PM

Reply With Quote

Bookmarks