function($variable) in PHP

T

TheJkWhoSaysNi

Guest
function name($variable) in php.

This works.
Code:
<?
function content($what) {
echo "$what";
}

content("Test");
?>

but putting it in a practical script, i cant get it to work at all.
Code:
...snip....

function content($what) {
	
echo $what;
  global $username, $db;
$sql="SELECT * FROM yabbse_members WHERE memberName = '$username'";
$result=mysql_query($sql,$db);
$row = mysql_fetch_array($result);
$membergroup = $row["memberGroup"];
echo("$what");
   if ($membergroup == 'Administrator') echo "
   <script language=\"JavaScript\">
   <!--
   function webed(content) {
      window.open('edit.php?content=' + content,'editwin','resizable=yes,width=600,height=380');
   }
   -->
   </script>
   ";
   
   $contentfile = "content/" . $what . ".html";
      if (is_file($contentfile)) {
      include $contentfile;
   }
   else echo"Unable to load $what";

   if ($membergroup == 'Administrator') {
      echo " <a href=\"javascript:webed('$what')\" target=\"_self\" 
        onMouseOver=\"status='$mouseover_str';return true\" onMouseOut=\"status='';return true\">
        <img src=\"images/edit.gif\" width=\"20\" height=\"15\" border=\"0\" alt=\"$mouseover_str\"></a>";
   }
   echo "";
    


}
...snip...

            $sql="SELECT * FROM Pages WHERE Page = '$page'";
            $result=mysql_query($sql,$db);
            $row = mysql_fetch_array($result);
            $type = $row["Type"];
            $member = $row["Member"];
            $admin = $row["Admin"];
            $customhead = $row["head"];
            
echo("Type: $type");
$title = str_replace('_', ' ', $page);

if ($customhead != '') 
$head = $customhead;

include("header.php");

echo("header.php....ok");

if ($member == '1') 
member();

if ($admin == '1') 
admin();

if ($type == '1') 
content("$page");

include("footer.php");


?>

My other functions work fine its just the content once wont. the script is at http://www.ud.barrysworld.net/indextest.php?page=Ranks and $page is from the URL.

if i comment out if ($type == '1') it works. and as you can see Type does echo as 1.

Any ideas why it wont work? Thanks.
 
S

(Shovel)

Guest
On a site note:
Best viewed at 1024*768 in Internet Explorer 5 or higher
No No No! Standards compliance is your friend damnit!

And now back to your regularly scheduled PHP helpers....
 
T

TheJkWhoSaysNi

Guest
Hmm, I can get by without that IF, if its possible to execute code that is stored within a database, i tried this:

$content = $row['content'];

$content;

but it diddnt work. If thats possible it will be easier...
 
T

TheJkWhoSaysNi

Guest
No No No! Standards compliance is your friend damnit!

It should work with most browers, but I know opera doesnt display the tables correctly (It messes up the borders colours) should be fine in mozilla (Although i have not tested it). It does infact work with IE4 although the javascript used on 1 page does not.
 

Users who are viewing this thread

Top Bottom