|
-
June 23rd, 2009, 12:31 AM
#1
PHP Call to a member function on a non-object - Help!
Hi There,
I have come across a very frustrating issue, which I see is quite a popular one. The following bit of code saves information to an XML file, but since upgrading to PHP 5.2.0 I get the following error:
Call to a member function on a non-object
It is very difficult for us (virtually impossible) to downgrade our version of PHP both from an infrastructural point of view, and also we need to ensure we have the latest version.
I would really appreciate it if anyone could be of assistance in helping me change the code below. The two critical lines in each are:
$this->questions[$idx]->setQuestionText($questionField);
$this->questions[$question_index_id]->fields[$field_index_id]->setHint($hint);
Code snippet:
Code:
function getContdevEditorOutput($challenge_id=0,$tutorial_id=0) {
$this->challenge_id = $challenge_id;
$this->tutorial_id = $tutorial_id;
//error_reporting(E_ALL);
$form = (isset($_POST['formvars']) ? $_POST['formvars'] : array());
// check if form was submitted - all returned
if(isset($form['nodeEditForm']) && $form['elementToEdit']=="allfields") {
// save question text
$questionTextFields = $form['saveQText'];
echo "QUESTIONS:<br><br>";
print_r($this->questions);
foreach($questionTextFields as $idx=>$questionField)
{
$this->questions[$idx]->setQuestionText($questionField);
}
// save hints
$hints = $form['saveHint'];
foreach($hints as $idx=>$hint) {
$refArr = explode("_",$idx);
$question_index_id = $refArr[0];
$field_index_id = $refArr[1];
$this->questions[$question_index_id]->fields[$field_index_id]->setHint($hint);
}
// option texts
$options = $form['saveOptionText'];
foreach($options as $idx=>$option) {
$refArr = explode("_",$idx);
$question_index_id = $refArr[0];
$field_index_id = $refArr[1];
$option_index_id = $refArr[2];
if(!isset($questions[$question_index_id]))
$this->questions[$question_index_id]->fields[$field_index_id]->options[$option_index_id]->setLabel($option);
//print "<br/>IDX:".$idx;
//print_r($option);
}
Regards,
James Dey
Last edited by PeejAvery; June 23rd, 2009 at 06:16 AM.
Reason: Added code tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|