Fatal error: Call to a member function fetch_array() on a non-object in


I have this error after I restore a backup of my OJS (only code & files):
Fatal error: Call to a member function fetch_array() on a non-object in /home4/oajpc/public_html/pages/index/IndexHandler.inc.php on line 874.
Can anyone help me with this error.

Thank you very much!

Best regards,
Mihai G.

It looks like you have made some extensive customizations to this page.

This error message indicates that the variable you are using to call fetch_array() is not actually an object. This is often the case with a failed instanciation.

We may be able to offer more comments if you can post the specific code section (or better yet, post a link to it on Github, if possible).

I put the content of the entire file here: IndexHandler.inc.php · GitHub

Best regards,

@medico, I get an access denied error when accessing that URL.

Here is the specific code section:

874	while ($row = $rs->fetch_array()){						
875					//echo $row[0];die;		
876	//				SELECT * FROM `journal_custom` t JOIN `journals` j ON j.`journal_id`=t.journal_id WHERE `show_in_slider`='yes'		
877	//				ORDER BY j.`seq` ASC		
878					$q2 = 'SELECT show_in_slider,id, rollover_text, url FROM journal_custom WHERE journal_id='.$row[0];		
879					$slider_rs = $mysqli->query($q2);		
880					$slider_row = $slider_rs->fetch_array();		
881					//echo '<pre>';print_r($slider_row);die;		
883					$q3 = 'SELECT path FROM journals WHERE journal_id='.$row[0];		
884					$path_rs = $mysqli->query($q3);		
885					$path_row = $path_rs->fetch_array();		
887					if(strtolower($slider_row[0]) == "no")		
888					continue;		
890					$pos1 = strpos($row[3],'journalThumbnail_en_US');		
891					$pos2 = strpos($row[3],'"', $pos1);		
892					$img = substr($row[3], $pos1, $pos2-$pos1);		
893					$img_url = $journalImageBasePath.$row[0].'/'.$img.'?'.time().'"';		
895					$slider_img .= sprintf('<li class="j_slide_li">		
896							       <a href="%s" class="tooltip"> <span>%s</span>
897							       <img src="%s" /></a></li>'
898							       ,$slider_row[3], $slider_row[2], $img_url);
900				}

The important bit will be how you instanciated $rs in the first line, and whether you are testing for a failure to build the $rs object if an error occurs.

Now it is working the link with the content of the file ndex/IndexHandler.inc.php:

Best regards,
Mihai G.

You should be checking the result of line 721:

$rs = $mysqli->query($q);

before attempting to use the object.

See, for example, lines 34-40 here: