Jump to content

cant make content search work


SusieWoosey

Recommended Posts

(php Server version: 4.0.25-standard) (MySQL client version: 4.1.22)

 

Hi all,

 

I am not very clever with .php, but can usually modify something to make it work for me. However, I cannot figure out what this error message is telling me -

 

Fatal error: Call to a member function on a non-object in /home2/andibrad/public_html/16mm/searchmagindex-testnewsearch.php on line 437

 

 

Line 437 in my code is -

 

if ($_POST["searchtitle"] || $_POST["searchcontent"]) $search_results = $db->get_results($search_sql);

 

How does the error relate to the php code? What is the error telling me is wrong? Or is it that my php/mysql just doesn't understand it?

 

 

Suzanne Bradley

 

ps. I can post the whole of the search code if necessary but it is rather long. The code can be seen at http://www.webmastersherpa.com/content/useful-code/32/#c5t_form

Link to comment
https://forums.phpfreaks.com/topic/100536-cant-make-content-search-work/
Share on other sites

Hi Barand,

Thank you for replying. Well I think I understand what you say. I've looked at the code, $db is declared as global as far as I can see in a function at the beginning of the code...

 

function prepare_results($search_results) {

global $db, $q, $s_array, $searchterm, $exact_term, $exact_term_array;

if ($search_results) {

foreach ($search_results as $search_result) {

$relevancy = 0;

$match = 0;

$context = "";

 

this is the first few lines of the function.

 

The only other time $db is used, is at the end of the code, not inside a function, on line 437 where it all falls to pieces and I get the error.

 

$search_sql .= ' )';

// echo "search sql is " . $search_sql . "<br />";

 

// --------------------------------------------------------------------------------

// --- now do the actual content search...

// --------------------------------------------------------------------------------

if ($_POST["searchtitle"] || $_POST["searchcontent"]) $search_results = $db->get_results($search_sql);  <-- line 437

 

 

// --------------------------------------------------------------------------------

// --- now prepare the results (assign relevancy AND select context text)...

// --------------------------------------------------------------------------------

$results_array = prepare_results($search_results);

 

 

// --------------------------------------------------------------------------------

// --- finally, display the results...

// --------------------------------------------------------------------------------

display_results($results_array);

 

this is the last few lines of the code.

 

 

Sorry if my ramblings are incoherent, I am not a php programmer. Just hoping to sort it out and make it work.

 

 

Suzanne Bradley

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.