Fatal error

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 2904 Views - Last Post: 19 April 2010 - 04:14 PM Rate Topic: -----

#1 Charlie21  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 15
  • Joined: 17-April 10

Fatal error

Posted 17 April 2010 - 12:54 PM

We have a recipe site and it was working fine til today.

We now get this message when we want to view the site.
Course:

Fatal error: Call to a member function MoveNext() on a non-object in /home/yepadmin/public_html/phprecipebook/themes/default/header.php on line 54


This is the url of the site

http://www.yorkshire.../phprecipebook/

Any help would be appreciated.


thanks in advance

Is This A Good Question/Topic? 0
  • +

Replies To: Fatal error

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4332
  • View blog
  • Posts: 12,126
  • Joined: 18-April 07

Re: Fatal error

Posted 17 April 2010 - 01:15 PM

It helps when we actually see the code you are writing to tell you exactly what is wrong. However, the problem arises from the fact that you attempt to use an object without first creating an instance of it. This can be caused by you forgetting to create an instance (which I am thinking is not the case if you already had it working) or by using an object that you thought would be created each time and it wasn't.

For instance, if you call a function that should return a Car class instance and instead something happens where it returns NULL and then you try to use it as a Car class by calling its Drive() function, then it will cause the error because the object is NULL, not a car.

So you might want to show us the code so that we can tell you where it might be causing your object to not be created properly.

Thanks! :)

This post has been edited by Martyr2: 17 April 2010 - 01:16 PM

Was This Post Helpful? 0
  • +
  • -

#3 Charlie21  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 15
  • Joined: 17-April 10

Re: Fatal error

Posted 17 April 2010 - 01:25 PM

<html>
<head>
<title><?php echo $g_rb_project_name; ?></title>
</head>
<link rel="stylesheet" href="./themes/<?php echo $g_rb_theme;?>/style.css" type="text/css">
<?php
// If we are print mode, then do not do most of the header
if ($print == "no") {
?>
<body bgcolor=#FFFFFF topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" background="./themes/<?php echo $g_rb_theme;?>/images/bground.png">

<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
	<td bgcolor="#006699" colspan="2"><img src="./images/logo.png">&nbsp;</td>
	<td rowspan="2" bgcolor="#006699"><img src="./themes/<?php echo $g_rb_theme;?>/images/pixel.png" width="20" height="1" border="0" alt="" align="top"></td>
</tr>
<tr>
	<td align="right" class="nav" width="100%" nowrap>
		<a href="index.php?m=recipes"><?php echo $LangUI->_('A-Z'); ?></a> | 
		<?php if ($SMObj->getUserLoginID()!="") {
			echo "<a href=\"index.php?m=favourites\">". $LangUI->_('Favourites') . "</a> | ";
		}?>
		<a href="index.php?m=recipes&a=search"><?php echo $LangUI->_('Search'); ?></a> | 
		<?php 
			if ($SMObj->checkAccessLevel("AUTHOR")) 
				echo '<a href="index.php?m=recipes&a=addedit">' . $LangUI->_('Add Recipe') . '</a> | ';
		?>
		<a href="index.php?m=lists&a=current"><?php echo $LangUI->_('Shopping List'); ?></a> | 
		<?php 
			if ($SMObj->getUserLoginID()!="") 
				echo '<a href="index.php?m=lists&a=saved">' . $LangUI->_('Saved Lists') . '</a> | ';
		?>
		
		<a href="index.php?m=misc&a=converter"><?php echo $LangUI->_('Converter'); ?></a> |
		<a href="index.php?m=data&a=export"><?php echo $LangUI->_('Data'); ?></a> 
		<?php if ($SMObj->getUserLoginID()!="") { ?>		
		| <a href="index.php?m=admin"><?php echo $LangUI->_('Settings');?></a>
		<?php } ?>
	</td>
	<td valign="top" align="right" width="14">
		<img src="./themes/<?php echo $g_rb_theme;?>/images/outercorner.png" width="14" height="14" border="0" alt="" hspace="0" vspace="0" align="top">
	</td>
</tr>
</table>
<table cellspacing="0" cellpadding="3" border="0" width="100%">
<tr valign=top>
	<td valign="top" class="nav" width="115">
		<img src="./themes/<?php echo $g_rb_theme;?>/images/pixel.png" width="115" height="1" border="0" alt="" align="top">
		<b><?php echo $LangUI->_('Course');?>:</b><?php
	$sql = "SELECT course_id,course_desc FROM $db_table_courses ORDER BY course_desc";
	$rc = $DB_LINK->Execute( $sql );
	while (!$rc->EOF) {
		echo '<br><A HREF="index.php?m=recipes&a=search&search=yes&course_id='.$rc->fields['course_id'].'">'.$rc->fields['course_desc'].'</A>';
		$rc->MoveNext();
	}
?>
		<p><b><?php echo $LangUI->_('Base');?>:</b><?php
	$sql = "SELECT base_id,base_desc FROM $db_table_bases ORDER BY base_desc";
	$rc = $DB_LINK->Execute( $sql );
	while (!$rc->EOF) {
		echo '<br><A HREF="index.php?m=recipes&a=search&search=yes&base_id='.$rc->fields['base_id'].'">'.$rc->fields['base_desc'].'</A>';
		$rc->MoveNext();
	}
	if ($SMObj->isSecureLogin())
		$SMObj->getLoginForm(NULL,"./index.php?m=users&a=register");
?>
	</td>
	<td width="6">&nbsp;</td>
	<td>
<?php
}
?>


I am only an amateur and still learning so I posted the whole of the code in the file. Hope that is okay. :)

This post has been edited by Martyr2: 17 April 2010 - 01:27 PM
Reason for edit:: Please use code tags in the future, thanks!

Was This Post Helpful? 0
  • +
  • -

#4 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4332
  • View blog
  • Posts: 12,126
  • Joined: 18-April 07

Re: Fatal error

Posted 17 April 2010 - 01:32 PM

Well apparently your variable $rc is not valid. This variable is generated from your statement...

$sql = "SELECT course_id,course_desc FROM $db_table_courses ORDER BY course_desc";
$rc = $DB_LINK->Execute( $sql );



Now if there is something wrong with your sql query statement it will cause a problem. So you might want to check to see if that query works. Make sure that $db_table_courses holds the value you think it does, that the columns you are using are spelled correctly and that $DB_LINK->Execute is going to return a valid object. If your SQL query is bad or your $DB_LINK object is not returning a valid object, then you are going to have $rc set to NULL or false meaning that your call to movenext() is not going to work.

:)

This post has been edited by Martyr2: 17 April 2010 - 01:33 PM

Was This Post Helpful? 0
  • +
  • -

#5 Charlie21  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 15
  • Joined: 17-April 10

Re: Fatal error

Posted 17 April 2010 - 01:40 PM

I have just had a thought. We were upgraded to PHP5. Could that be the problem as it worked fine before that? If yes can we do anything to make it work again?
Was This Post Helpful? 0
  • +
  • -

#6 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4332
  • View blog
  • Posts: 12,126
  • Joined: 18-April 07

Re: Fatal error

Posted 17 April 2010 - 01:46 PM

There is indeed a significant set of changes between the PHP 4 line and the PHP5 line. Many changes affect how objects work. So that could very well be a problem that is causing your $DB_LINK object not work quite right. First thing I would do is make sure you know where the problem is. After where you set $rc put in a line like...

$sql = "SELECT course_id,course_desc FROM $db_table_courses ORDER BY course_desc";
$rc = $DB_LINK->Execute( $sql );

// Put in this test line and rerun the page
echo "SQL is: $sql<br/>RC is: $rc<br/>";



And then you will see your query statement and if it looks ok and to see if $rc is actually set to a value. You can show us the results of this line after you run it.

:)
Was This Post Helpful? 0
  • +
  • -

#7 Charlie21  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 15
  • Joined: 17-April 10

Re: Fatal error

Posted 17 April 2010 - 01:56 PM

Done that and now get this

Course:SQL is: SELECT course_id,course_desc FROM recipe_courses ORDER BY course_desc
RC is:


Fatal error: Call to a member function MoveNext() on a non-object in /home/yepadmin/public_html/phprecipebook/themes/default/header.php on line 58
Was This Post Helpful? 0
  • +
  • -

#8 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2911
  • View blog
  • Posts: 10,079
  • Joined: 08-August 08

Re: Fatal error

Posted 17 April 2010 - 02:15 PM

It looks to me like that page is supposed to be an include to another page. Are you trying to call it directly?
Was This Post Helpful? 0
  • +
  • -

#9 Charlie21  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 15
  • Joined: 17-April 10

Re: Fatal error

Posted 17 April 2010 - 02:23 PM

Sorry, I don't really know. It was working fine and nothing has been changed in any of the files.

I haven't been doing this for long.
Was This Post Helpful? 0
  • +
  • -

#10 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4332
  • View blog
  • Posts: 12,126
  • Joined: 18-April 07

Re: Fatal error

Posted 17 April 2010 - 02:26 PM

View PostCharlie21, on 17 April 2010 - 11:56 AM, said:

Done that and now get this

Course:SQL is: SELECT course_id,course_desc FROM recipe_courses ORDER BY course_desc
RC is:


Fatal error: Call to a member function MoveNext() on a non-object in /home/yepadmin/public_html/phprecipebook/themes/default/header.php on line 58


You see how nothing was printed after "RC is:" ? That means your $DB_LINK class has an issue. It is not returning an actual object and that is going to cause the problem you have with MoveNext. So our focus should now be with $DB_LINK. If you had no problem with this in PHP 4 and now have problems with it in PHP 5, it is probably how the class that $DB_LINK represents (and its method execute) was defined.

The main problem is going to be in the Execute function of whatever class $DB_LINK is defined as. :)
Was This Post Helpful? 0
  • +
  • -

#11 Charlie21  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 15
  • Joined: 17-April 10

Re: Fatal error

Posted 17 April 2010 - 02:40 PM

Thanks for your help so far. I have to go now. Will be back tomorrow evening. :)
Was This Post Helpful? 0
  • +
  • -

#12 Charlie21  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 15
  • Joined: 17-April 10

Re: Fatal error

Posted 18 April 2010 - 12:07 PM

View PostMartyr2, on 17 April 2010 - 01:26 PM, said:

View PostCharlie21, on 17 April 2010 - 11:56 AM, said:

Done that and now get this

Course:SQL is: SELECT course_id,course_desc FROM recipe_courses ORDER BY course_desc
RC is:


Fatal error: Call to a member function MoveNext() on a non-object in /home/yepadmin/public_html/phprecipebook/themes/default/header.php on line 58


You see how nothing was printed after "RC is:" ? That means your $DB_LINK class has an issue. It is not returning an actual object and that is going to cause the problem you have with MoveNext. So our focus should now be with $DB_LINK. If you had no problem with this in PHP 4 and now have problems with it in PHP 5, it is probably how the class that $DB_LINK represents (and its method execute) was defined.

The main problem is going to be in the Execute function of whatever class $DB_LINK is defined as. :)

Hello again

Where can I find this info please?
Was This Post Helpful? 0
  • +
  • -

#13 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2911
  • View blog
  • Posts: 10,079
  • Joined: 08-August 08

Re: Fatal error

Posted 18 April 2010 - 01:16 PM

Possibly in whatever file included or required your code.
Was This Post Helpful? 0
  • +
  • -

#14 Charlie21  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 15
  • Joined: 17-April 10

Re: Fatal error

Posted 19 April 2010 - 01:59 AM

I spent quite a while looking through the files and found this. Is this where something has to be changed?
<?php 
global $SMObj, $DB_LINK, $LangUI;
// Include the required files
require_once("includes/config_inc.php");
require_once("custom_inc.php"); // override the default settings here
require_once("phpSecurityManager/core_API.php");
require_once("includes/LangUI.class.php");
require_once("includes/functions.php");
// Create the security object and retrieve the database object
$SMObj = newSecurityModel("database"); // is one option
$SMObj->setDataSource($g_rb_database_type,$g_rb_database_host,$g_rb_database_user,$g_rb_database_password,$g_rb_database_name);
$SMObj->openDataSource(); // open the connection

$DB_LINK = $SMObj->getDataSource(); // get the database connection object (adodb)

$LangUI = new LangUI; // handles translations
$browser_lang = getBrowserLanguage();

// Load the language file based on config or logged in user
if ($SMObj->getUserLoginID() != NULL) {
	$userID = $SMObj->getUserLoginID();
	$details = $SMObj->getUserDetails($userID);
	include "lang/".$details['language'].".php";
} else if ($browser_lang != NULL) {
	//we found a browser match load it.
	include "lang/".$browser_lang.".php";
} else {
	//nothing matched, load the default
	include "lang/".$g_rb_language.".php";
}

// Convience debugging option, shows what version the database thinks it is.
if ($g_rb_debug) checkDBSchemaVersion();

// langArray is set in en.php, it.php...etc..
$LangUI->setLangArray( $langArray );
$SMObj->setTranslationObject($LangUI); // pass that info on to the security manager
if ($SMObj->isSecureLogin())
	$SMObj->getLoginFormSubmit();
else {
	// auto login
	if ($SMObj->getUserLoginID() == "")
		$SMObj->login();
}

// End of Login/Session stuff, now on to displaying the page //
// m = the module, cf modules directory, eg 'search'
$m = isset( $_GET['m'] ) ? $_GET['m'] : 'recipes';

// a = action, default is the index page of the module
$a = isset( $_GET['a'] ) ? $_GET['a'] : 'index';

// print = format for printing (minimal formating)
$print = isset( $_GET['print'] ) ? $_GET['print'] : 'no';

// Load the CSS and theme/header stuff
require "themes/$g_rb_theme/style_inc.php";
require "themes/$g_rb_theme/header.php";

if (!empty( $_REQUEST['dosql'] )) {
	include "modules/$m/".$_REQUEST['dosql'].".php";
}

include "modules/$m/$a.php";

require "themes/$g_rb_theme/footer.php";

saveSecurityModel($SMObj);
$LangUI->cleanUp();
?>

This post has been edited by JackOfAllTrades: 19 April 2010 - 05:43 AM
Reason for edit:: Added code tags.

Was This Post Helpful? 0
  • +
  • -

#15 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6048
  • View blog
  • Posts: 23,473
  • Joined: 23-August 08

Re: Fatal error

Posted 19 April 2010 - 05:45 AM

Honestly, if you don't know any PHP, and it certainly seems that's the case, you're probably in way over your head and this is going to be very frustrating for all involved.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2