whats wrong with my 2 functions?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tinoda
Forum Commoner
Posts: 33
Joined: Mon Dec 29, 2008 3:32 am

whats wrong with my 2 functions?

Post by tinoda »

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

Code: Select all

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">&nbsp;</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">&nbsp;</td></tr>';
 
      echo '<tr><td></td><td height="1" class="line" colspan="3"></td><td></td></tr>';
 
       echo '<tr><td colspan="5">&nbsp;</td></tr>';
 
 
 
 
 
   }
 
}
function 2

Code: Select all

function endElement($parser, $name)
 
{
 
   global $imageArray;
 
   global $hit;
 
   if ($name == "RECORD") {
 
     $score = number_format(($hit["SCORE"] * 100), 1, '.', " ");
 
     print '<tr>
 
                <td>&nbsp;</td>
 
                <td align="left" valign="top">'
 
                .'['.$score.'%]&nbsp;</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>&nbsp;&nbsp;(' . $hit["LASTCHANGED"] . ')</td>';
 
      $contentType=strtoupper($hit["CONTENTTYPE"]);
 
      if (isset($imageArray[$contentType])) {
 
           //-----$content = '<img src="'.$imageArray[$contentType].'" alt="'.$contentType.'" />';
 
      } else {
 
          $content = "&nbsp;";
 
      }
 
      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">&nbsp;</td></tr>'
 
           . '<tr><td></td><td height="1" class="line" colspan="3"></td><td></td></tr>'
 
           . '<tr><td colspan="5">&nbsp;</td></tr>';
 
 
 
   }
 
}
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: whats wrong with my 2 functions?

Post by requinix »

Where's the part in your post where you describe the problem(s) you're having?
tinoda
Forum Commoner
Posts: 33
Joined: Mon Dec 29, 2008 3:32 am

Re: whats wrong with my 2 functions?

Post by tinoda »

tasairis wrote:Where's the part in your post where you describe the problem(s) you're having?
I have a long script that i have created and if i run it i get an empty white page which signifies an error in my cms. But the moment i cut those 2 functions my script gets to run properly but i need those 2 fucntions to be working well for me to work out my search engine. my main problem therefore is that i am not sure where the problem lies in my 2 functions.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: whats wrong with my 2 functions?

Post by jackpf »

Turn on error reporting.
tinoda
Forum Commoner
Posts: 33
Joined: Mon Dec 29, 2008 3:32 am

Re: whats wrong with my 2 functions?

Post by tinoda »

jackpf wrote:Turn on error reporting.
Okay i have double checked my errors and i am getting the dreaded parse error like this:

"parse error in X:\Programme\sasasas0\www\asaas.php on line 432"
tinoda
Forum Commoner
Posts: 33
Joined: Mon Dec 29, 2008 3:32 am

Re: whats wrong with my 2 functions?

Post by tinoda »

tinoda wrote:
jackpf wrote:Turn on error reporting.
Okay i have double checked my errors and i am getting the dreaded parse error like this:

"parse error in X:\Programme\sasasas0\www\asaas.php on line 432"
i have finally solved it by myself. i realised that i forgot a ; after the first print statement in fucntion 2. thank you all for trying to help me.
Post Reply