PDA

View Full Version : y do false functions stop my script?


megahard
Mon 10th Jun '02, 1:08pm
i have a function, and it needs the variable 'pid' to work.

// Function to take basic template and put the title and information into it
function displaypage($pid=-1){
global $queries;

if($pid != -1){
// Get page info
$queries->query("SELECT * FROM br_announce WHERE pid=$pid");
$info_array = mysql_fetch_array($queries->query);

// Get template
$queries->query("SELECT * FROM br_layouts WHERE lid=2");
$template = mysql_fetch_array($queries->query);

$pagetoecho = str_replace("<%title%>", $info_array[0], $template[1]);
$pagetoecho = str_replace("<%body%>", $info_array[1], $pagetoecho);
return $pagetoecho;
}
}


if i don't include the variable pid or it doesn't exist, then as i'd expect, the function does nothing.

but y does it stop everything below it?
echo displaypage($pid);

echo displaymenu();

echo displaynews();

it stops both displaymenu() and displaynews() from being executed

scoutt
Mon 10th Jun '02, 1:44pm
maybe it is because you didn't tell it to return? just a guess, but if pid=-1 then it should run right through that function. must be something else.

I can't see that it would stop other functions from running.

megahard
Mon 10th Jun '02, 2:02pm
function displaypage($pid=-1){
if($pid != -1){
global $queries;
// Get page info
$queries->query("SELECT * FROM br_announce WHERE pid=$pid");
$info_array = mysql_fetch_array($queries->query);

// Get template
$queries->query("SELECT * FROM br_layouts WHERE lid=2");
$template = mysql_fetch_array($queries->query);

$pagetoecho = str_replace("<%title%>", $info_array[0], $template[1]);
$pagetoecho = str_replace("<%body%>", $info_array[1], $pagetoecho);
return $pagetoecho;
}
}

if i put the global variable within the IF then it works, i duno, o well

Dan615
Mon 10th Jun '02, 2:18pm
function displaypage($pid=-1){
global $queries;
if($pid != -1){
// Get page info
$queries->query("SELECT * FROM br_announce WHERE pid=$pid");
$info_array = mysql_fetch_array($queries->query);

// Get template
$queries->query("SELECT * FROM br_layouts WHERE lid=2");
$template = mysql_fetch_array($queries->query);

$pagetoecho = str_replace("<%title%>", $info_array[0], $template[1]);
$pagetoecho = str_replace("<%body%>", $info_array[1], $pagetoecho);
return $pagetoecho;
}
return 0;
}

That'll return false if it doesn't work...

megahard
Mon 10th Jun '02, 2:45pm
it turned out i was being a retard and put die() in my class, so that everytime sumthing was wrong it ended the script.

darn