Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
Donovan
Client



Joined: Oct 07, 2003
Posts: 735
Location: Ohio

PostPosted: Fri Jan 28, 2005 9:00 pm Reply with quote

I get the following error when calling a page loaded in my admin directory in Nuke. It is a custom module I have been working on for awhile now.

Quote:
Fatal error: Call to a member function on a non-object


Code:
$sql = "SELECT uniqueid, u_handle FROM roster_members";

$result = $db->sql_query($sql);   
while ( $row = $db->sql_fetchrow($result) ) {
   $id = $row["uniqueid"];
   $name = $row["u_handle"];


The line is the $result line in the error message located in public_html/admin/modules/milpacs.php on line 69.


The top part of this page looks like this.

Code:
if (!eregi("admin.php", $PHP_SELF)) { die ("Access Denied"); }


$result = sql_query("select radminsuper, radminency from ".$prefix."_authors where aid='$aid'", $dbi);
list($radminency, $radminsuper) = sql_fetch_row($result, $dbi);
if (($radminency==1) OR ($radminsuper==1)) {   
 switch($op) {
      case "milpacs";
         milpacs();
         break;
   }
}
else {
   echo "Access Denied";
 
View user's profile Send private message Visit poster's website ICQ Number
chatserv
Member Emeritus



Joined: May 02, 2003
Posts: 1389
Location: Puerto Rico

PostPosted: Fri Jan 28, 2005 9:50 pm Reply with quote

First thing to check through phpMyAdmin is that the roster_members table exists and that it has the uniqueid and u_handle fields, if that checks ok and if using Nuke 7.5 or 7.6 then the error is caused by:
Code:
$result = sql_query("select radminsuper, radminency from ".$prefix."_authors where aid='$aid'", $dbi); 

list($radminency, $radminsuper) = sql_fetch_row($result, $dbi);
if (($radminency==1) OR ($radminsuper==1)) {

as radminency no longer exists in 7.5 and 7.6 in which case you'd have to change it to:
Code:
$result = sql_query("select radminsuper from ".$prefix."_authors where aid='$aid'", $dbi); 

list($radminsuper) = sql_fetch_row($result, $dbi);
if ($radminsuper==1) {
 
View user's profile Send private message Visit poster's website
PHrEEkie
Subject Matter Expert



Joined: Feb 23, 2004
Posts: 358

PostPosted: Fri Jan 28, 2005 10:07 pm Reply with quote

To add to what Chat has said, the most common reason for Fatal error: Call to a member function is leaving $db out of the globals in a function.

In the above code posted, you are using both $db and the deprecated $dbi. You should convert the deprecated SQL calls to the new layering format which is
Code:
$db->sql_query


etc..


That being said, if the script loads mainfile.php (via require_once), then $db is available. However, if you pass program scope to a function (case "milpacs"), then you must add as the first line of the function_milpacs:
Code:
global $db;


If that isn't in there, then you'll receive the error you posted. Almost 100% of those exact errors are caused by
Code:
$something->$something_else


PHrEEk
 
View user's profile Send private message
Donovan







PostPosted: Fri Jan 28, 2005 10:30 pm Reply with quote

I am running Nuke 7.3 and have both fields in roster_members.

I declared"
Code:


global $module_name, $db;
but did that outside of my milpacs function

I added that as my first line under function milpacs() {

and pow... everything is rosy. Smile

Thanks
 
PHrEEkie







PostPosted: Fri Jan 28, 2005 10:44 pm Reply with quote

Donovan wrote:
everything is rosy. Smile

Thanks


More than welcome...

And I see your nym listed in the donations section, soo... thank you! Smile

PHrEEk
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©