• Help
  • Search
  • Login
  • Register
  • Home

Forum: web design and graphics community

Celestial Star Forum > Web Development > Coding > Ok, i dont usually ask for help
Pages: [1]
« previous next »
  Print  
Author Topic: Ok, i dont usually ask for help  (Read 622 times)
DaviDJ
Angeling
*
Posts: 8


View Profile
Ok, i dont usually ask for help
« on: May 14, 2005, 07:37:31 AM »

I'm having trouble with Classes in PHP... I am new to them so i dont get how they work as of yet... here is my code...

Code:

<?php
include&#40;"Functions.global.php"&#41;;

class Security
&#123;
  
function getPriv&#40;$id,$page&#41;
  
&#123;
    
global $gGlobal;
    
# Connect to the database via another class
    
$gGlobal->Connect&#40;&#41;;
    
$pl = mysql_query&#40;"SELECT id,user,rank,ip FROM `players` WHERE id='$id'"&#41;;
    
$pl = mysql_fetch_array&#40;$pl&#41;;
    # Get Privileges for page
    
$priv  = mysql_query&#40;"SELECT * FROM page_privileges WHERE global_setting='$page'"&#41;;
    
if &#40;!$priv&#41;
    
&#123;
      
$msg = "No Privileges set for this page.";
      
$end = 1;
    &
#125;
    
else
    &
#123;
      
$priv = mysql_fetch_array&#40;$priv&#41;;
    
&#125;
    
if &#40;$end != "1" && $priv&#41;
    
&#123;
      
$plrank = $pl[rank&#93;;
      
if &#40;$priv[$plrank&#93; == "0"&#41;
      
&#123;
        
$msg = "<b>Error&#58;</b> You do not have permission to be here.";
        
$end = 1;
      &
#125; else &#123;
        
$msg = "You have permission to access this page.";
      &
#125;
    
&#125;
    
else
    &
#123;
      
$msg = "No Privileges set for this page.";
      
$end = 1;
    &
#125;
    
if &#40;$msg&#41;
    
&#123;
      
$errmsg->Message&#40;$msg&#41;;
    
&#125;
    
return $end;
  &
#125;
&#125;
$admin = new Security;

class 
ErrMessage extends Security
&#123;
  
function Message&#40;$msg&#41;
  
&#123;
    
global $smarty;
    
#$msg = "<div align=center>" . $msg . "</div>";
    
$msg .= "<br>";
    echo 
$msg;
    
$smarty->display&#40;'footer.tpl'&#41;;
    
exit;
  &
#125;
&#125;
$errmsg = new ErrMessage;
?>



I get the error message:

Code:

Fatal error: Call to a member function on a non-object in /home/public_html/Functions.admin.php on line 42


That is the line:

      $errmsg->Message($msg);

I'm not sure how I can get that to work...

This class is basically a privilege thing for my game so i can set the ranks allowed to visit certain pages... Any questions about certain bits you can ask me... if you know whats wrong or what im doing wrong your help will be much appreciated...  :D  :D [/code]
Logged

color=red]DaviDJ[/color]
Pages: [1]
  Print  
« previous next »
 
Jump to:  

  • Welcome, Guest
  • Members login
  • Register for free

General

  • General
  • New members
  • Announcements
  • Support / Suggestions

Art boards

  • Creative mediums
  • Requests and offers
  • Tutorials
  • Celestial Star tutorials

Web development

  • Coding
  • Web design
  • Advertisements / affiliation

Off-topic

  • The non-sense
  • Ententainment

Go up
eXTReMe Tracker
  • Valid XHTML
  • Valid CSS
Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC | Seo4Smf v0.2 © Webmaster's Talks
Loading...