News:

Wondering if this will always be free?  See why free is better.

Main Menu

Include makes if statements not work

Started by Valconeye, January 11, 2004, 09:09:49 PM

Previous topic - Next topic

Valconeye

hehe, well basically in a nut shell yeah.

I have a theme system that uses the
switch($_GET["link"])
template where the $link is displayed
<? @include $link; ?>
so everything is included,

My problem is, when i include this page, http://www.warcraftwars.com/links/wowguilds.php (the style is included in the template, so this will be hard to read)
That page works fine, but when it goes through the include,
http://www.warcraftwars.com/index.php?link=wowguilds
The Order by stuff doesnt work.

this is the code in wowguilds.php
if ($db == "" || $order == "")
  {
  $query = "select * from guilds";
  $result = mysql_query($query);
  }
  elseif ($db == "name" || $order == "ASC")
  {
  $query = "select * from guilds ORDER BY name ASC";
  $result = mysql_query($query);
  }
 

etc.. the if statements go on.

[Unknown]

Shouldn't you be using $_GET or $GLOBALS?  Includes are basically functions, sorta, sometimes... so you have to global things.

-[Unknown]

Valconeye

so your saying instead of <? @include $link; ?> i should do?

mike9010

you need to use the global keyword or $GLOBALS if you use a variable from another file and/or function. It won't work other wise.

Valconeye

wooohoo, i finally figured it out. all i had to do was put my code into a function, and do global $db, $order;
Now it works with my theme system!
thanks for the help!!

Advertisement: