Jump to content

Recommended Posts

i am desigining a search engine which uses PHP and XML.  i have come up with a long code and after a long day of testing i am beginning to realise that the problem might be with my two functions below.  however i cant seem to figure out what exactly is wrong.  if you can pick up some errors on my 2 functions below i will appreciate hearing from you.  thank you and if u need more info please let me know.

 

FUNCTION 1

function startElement($parser, $name, $attrs)

{

   global $to;

   global $from;

   global $show;

   global $results;



   if (empty($_GET['start'])) {

       $start=1;

   } else {

       $start=$_GET['start'];

   }

   global $maxNum;

   global $tag;

   $tag = $name;

   if ($name == "RECORD") {

      global $hit;

      $hit = array("index" => "$attrs");

   }

   if ($name == "SEARCHRESULTS") {

       global $hits;

       $hits = $attrs["HITS"];

       echo '<tr><td colspan="5" height="10px"> </td></tr>';

       echo '<tr><td></td><td colspan="3">';

       if ($hits != 0) {

            if (($start+$maxNum-1) > $hits) {

                $end=$hits;

            } else {

                $end=$start+$maxNum-1;

            }

           print("<p>$show $start $to $end $from $hits $results.</p>");

      } else {

            global $nothing_found;

            echo $nothing_found;

      }

      echo '</td><td></td></tr>';

      echo '<tr><td colspan="5" height="10px"> </td></tr>';

      echo '<tr><td></td><td height="1" class="line" colspan="3"></td><td></td></tr>';

       echo '<tr><td colspan="5"> </td></tr>';





   }

}

FUNCTION 2

function endElement($parser, $name)

{

   global $imageArray;

   global $hit;

   if ($name == "RECORD") {

     $score = number_format(($hit["SCORE"] * 100), 1, '.', " ");

     print '<tr>

                <td> </td>

                <td align="left" valign="top">'

                .'['.$score.'%] </td>'

                . '<td>'

              //------  . '<a href="' . $hit["VISIBLEPATH"] . '">';

      if (empty($hit["TITLE"])) {

          $path=$hit["VISIBLEPATH"];

          ereg ("/(.*)/(.*)", $path, $regs);
          print $regs[2];
      } else {

          print $hit["TITLE"];

      }

      print '</a>  (' . $hit["LASTCHANGED"] . ')</td>';

      $contentType=strtoupper($hit["CONTENTTYPE"]);

      if (isset($imageArray[$contentType])) {

           //-----$content = '<img src="'.$imageArray[$contentType].'" alt="'.$contentType.'" />';

      } else {

          $content = " ";

      }

      print '<td>'. $content.'</td><td></td></tr>'

                . '<tr>

                    <td></td>

                    <td colspan="3">'

                    .$hit["SUMMARY"]

           . '</td><td></td></tr>';

      print '<td></td><td colspan="3">'.substr($hit["VISIBLEPATH"], 0, 100) .'</td><td></td></tr>'

           . '<tr><td colspan="5"> </td></tr>'

           . '<tr><td></td><td height="1" class="line" colspan="3"></td><td></td></tr>'

           . '<tr><td colspan="5"> </td></tr>';



   }

}

show us the errors you receive :)

 

my server does show errors but on this one it just goes blank and no error is displayed.  usually when that happens its a sign that the error is somehow very fatal. The moment i remove those 2 functions everything seems to run very well but i cant do a search engine without those 2 fucntions.  Unless if you want me to display my complete very long code

Hi

 

Not sure if it is just something caused when pasting here, but the 2nd script is missing a ; (at the end of the first print statement).

 

However I would expect that to flag up an obvious error.

 

All the best

 

Keith

 

Yes yes yes yes Keith that was the problem..the moment i put the ; everything went rolling. thanks for brightening my day.  all the best.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.