Go Back   SitePoint Forums > Forum Index > Program Your Site > PHP
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Jun 20, 2006, 13:43   #1
Gerto
SitePoint Zealot
 
Join Date: Jun 2005
Posts: 103
Fatal error: Class 'Menu' not found in ...

I've been getting this error for a long time now , and I just can't seem to solve it. When I try to load the page it gives this error,when I refresh however, it works perfectly????

PHP Code:

require_once("classes/menu.php");

$menu=new menu;
function
display_menu($position,$separator="<br/>")
{
    if(
User::is_loggedin())
    {
        
$r=Database::query("SELECT * FROM ".DB_PREFIX."_menu_positions WHERE (position='".$position."') LIMIT 1");
        while(
$row=mysql_fetch_array($r))
        {
            
menu::display_menu($row['position'],$separator);
        }
    }
}

PHP Code:

<?php

/*This file will be used to display the menu(s) */
class menu
{
    function
display_menu($name,$separator="<br/>")
    {

    
$r=Database::query("SELECT * FROM ".DB_PREFIX."_menu_positions WHERE(position='".$name."' AND displayed='true')");
        while(
$row=mysql_fetch_array($r))
        {
            
$id=$row['id'];
            echo
"<strong>".$row['name']."</strong>";
            
$r2=Database::query("SELECT * FROM ".DB_PREFIX."_menu_items WHERE(menu='".$id."')");
            while(
$row2=mysql_fetch_array($r2))
            {
                if(
$userdata['session_logged_in'])     //See if phpBB is integrated, if so; add sid to enable links to phpBB
                
{ // user is logged in
                    
echo "ollé";
                    
$link=append_sid($row2['link']);
                }
                else        
//phpBB is not integrated
                    
$link=append_sid($row2['link']);                
                echo
$separator."<a href='".$link."'>".$row2['value'].'</a>';
            }
            echo
"<br/>";
        }
    }
}
I'm sorry if the code is inefficient / ... , I'm completely new to classes and don't have too much experience with php. I hope the code is a bit clear, and someone will be able to help me with this, cause it's REALLY important that I find the solution within the next 10 hours (it's for school ).

Another remarkable thing: if I comment everything out about this class , exactly the same error comes up for the next class mentioned in the page (the code is about the same; and once again when the page is refreshed everythink works )


Thanks!!

Gert

Last edited by Gerto; Jun 20, 2006 at 14:59.
Gerto is offline   Reply With Quote
Old Jun 20, 2006, 13:48   #2
hifigrafix
SitePoint Evangelist
 
hifigrafix's Avatar
 
Join Date: Oct 2005
Posts: 574
should it be:

$menu= new menu();
hifigrafix is offline   Reply With Quote
Old Jun 20, 2006, 14:32   #3
Gerto
SitePoint Zealot
 
Join Date: Jun 2005
Posts: 103
Thanks hifigrafix! But that doesn't change anything.
Gerto is offline   Reply With Quote
Old Jun 20, 2006, 14:58   #4
briancastellanos
SitePoint Zealot
 
Join Date: May 2006
Location: Phoenix, AZ
Posts: 162
yeah...its a little sloppy.. can you use the sytax coloring pls..

use [ PHP ] and [ /PHP ]..


the User::is_loggedin(); what is this calling? why didn't you instatiate (sp??) user first?

I'm sure it is checking the session right? Remeber with sessions, when you set the value, it won't be available until the next refresh..

So once they login, you can't check if they're logged in until the next time they refresh or go to another page. This may be why it is failing.

Check to see what your classes are linked..are you using extensions??

Class Menu EXTENDS user ?
briancastellanos is offline   Reply With Quote
Old Jun 20, 2006, 15:30   #5
Gerto
SitePoint Zealot
 
Join Date: Jun 2005
Posts: 103
Quote:
Originally Posted by briancastellanos
I'm sure it is checking the session right? Remeber with sessions, when you set the value, it won't be available until the next refresh..

Thanks briancastellanos!

That was the problem, I now refresh the page immediately so the error doesn't occur,

Thanks, you saved the day ;-)

Gert
Gerto is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 16:01.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved