Jump to content


Photo

fatal error in php


  • Please log in to reply
8 replies to this topic

#1 9911782

9911782
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 02 October 2006 - 09:54 AM

Hi All

There is a website currently running, but Im not the developer i had to maintain it.But, im having a problem with searching.Somebody else have developed it. When performing the search function, I get this problem:

Fatal error: Call to a member function RecordCount() on a non-object in C:\Program Files\Business Objects\ThirdParties\apache\htdocs\Terminology\resultsABBR.php on line 37

here is the code of resultsABBR.php:
---------------------------------------------------------------
<html>
<head>
<title>Terminology: Search Results</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="800" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="center"><h2>Search Results</h2><br><img src="BS00554_.WMF" width="141" height="118">
</td>
</tr>
<tr>
<td><hr></td>
</tr>

<!--h2>Search Results</h2-->

<tr>
<td>
<?php
include('tblterminologyDAO.php');

// check if a search term has been given - to be replaced by built-in framework validation
if(!$abbr){
echo "No search term given";
exit;
}

if($language == 1){
$result = listAbbrevByEnglish($abbr);
} else if($language == 2){
$result = listAbbrevByAfrikaans($abbr);
} else{
$result = listAbbrevByXhosa($abbr);
}

if($result->RecordCount() == 0){
echo "<meta HTTP-EQUIV='REFRESH' content='0; url=error.php?phrase=".$abbr."'>";
exit;
} else{
echo "<table border='1' bordercolor='#000000'>
<tr>";
if($language == 1){
echo " <td><b>Abbreviation</b></td>
<td><b>Phrase/Word</b></td>
<td><b>Comment</b></td>
<td><b>Afkorting</b></td>
</tr>";
} else if($language == 2){
echo " <td><b>Afkorting</b></td>
<td><b>Frase/Woord</b></td>
<td><b>Opmerking</b></td>
<td><b>Abbreviation</b></td>
</tr>";
} else{
echo " <td><b>Abbreviation(Xho)</b></td>
<td><b>Phrase(Xho)</b></td>
<td><b>Comment(Xho)</b></td>
<td><b>Abbreviation</b></td>
<td><b>Afkorting</b></td>
</tr>";
}

while ($record = $result->FetchRow()) {
if($language == 1){
echo "<tr>
<td>".$record["ABBREVE"]."</td>
<td>".$record["PHRASEE"]."</td>
<td>".$record["COMMENTE"]."</td>
<td>".$record["ABBREVA"]."</td>
</tr>";
} else if($language == 2){
echo "<tr>
<td>".$record["ABBREVA"]."</td>
<td>".$record["PHRASEA"]."</td>
<td>".$record["COMMENTA"]."</td>
<td>".$record["ABBREVE"]."</td>
</tr>";
} else{
// Xhosa to be added

}
}
}
?>
</table>
</td>
</tr>
<tr>
<td height="45"></td>
</tr>
<tr>
<td width="50%" height="30" bgcolor="#000066" align="center">
<a href="main.html" style="color:#ffffcc;">Home</a> | <a href="javascript: history.go(-1)" style="color:#ffffcc;">Back</a>
</td>
</tr>
</table>
</body>
</html>
---------------------------------------------------------------
here is the code for 'tblterminologyDAO.php'
--------------------------
<?php
// include connection class
include ('conn.php');
include ('statementParser.php');

$db = connect();

// function to get data by english phrase/word
function listPhraseByEnglish($phraseEng){
global $db;
$preparedStatement[0] = $phraseEng;
$query = loadSql("tblterminologyDAO.listPhraseByEnglish", $preparedStatement);
$result = $db->Execute($query);
return $result;
}
// function to get data by afrikaans phrase/word
function listPhraseByAfrikaans($phraseAfr){
global $db;
$preparedStatement[0] = $phraseAfr;
$query = loadSql("tblterminologyDAO.listPhraseByAfrikaans", $preparedStatement);
$result = $db->Execute($query);
return $result;
}
// function to get data by xhosa phrase/word
function listPhraseByXhosa($phraseXho){
global $db;
$preparedStatement[0] = $phraseXho;
$query = loadSql("tblterminologyDAO.listPhraseByXhosa", $preparedStatement);
$result = $db->Execute($query);
return $result;
}
// function to get data by english abbreviation
function listAbbrevByEnglish($abbrEng){
global $db;
$preparedStatement[0] = $abbrEng;
$query = loadSql("tblterminologyDAO.listAbbrevByEnglish", $preparedStatement);
$result = $db->Execute($query);
return $result;
}
// function to get data by afrikaans abbreviation
function listAbbrevByAfrikaans($abbrAfr){
global $db;
$preparedStatement[0] = $abbrAfr;
$query = loadSql("tblterminologyDAO.listAbbrevByAfrikaans", $preparedStatement);
$result = $db->Execute($query);
return $result;
}
// function to get data by xhosa abbreviation
function listAbbrevByXhosa($abbrXho){
global $db;
$preparedStatement[0] = $abbrXho;
$query = loadSql("tblterminologyDAO.listAbbrevByXhosa", $preparedStatement);
$result = $db->Execute($query);
return $result;
}
?>
----------------------------

----------------------------
here is the code for 'statementParser.php
---------------------------
<?php
// define file name and create handle to open file for reading
$file = 'sql.inc.php';
$handle = fopen($file, "r");

// use fread, open for reading, how much? full size of $file.
$data = fread($handle, filesize($file));
fclose($handle);

// break up the data into an array, split where the new lines breaks are
$data_split = explode("##", $data);
for($i = 0; $i < count($data_split); $i++){
$data_split[$i] = str_replace("\\", "", $data_split[$i]);
}
$sqlData = processSql($data_split);

function loadSql($queryString, $parameters){
global $sqlData;
$query = $sqlData[$queryString];
$p = 0;
for($i = 0; $i < strlen($query); $i++){
$str_temp = substr($query, $i, 1);
if($str_temp == "?"){
$query = substr_replace($query,$parameters[$p],$i,1);
$p++;
}
}
return $query;
}

function processSql($sqlStringArray){
for($i = 0; $i < count($sqlStringArray); $i++){
$sqlString = trim($sqlStringArray[$i]);
$sqlValue = ereg_replace("([a-zA-Z0-9])+.([a-zA-Z0-9])+( )*=( )*","", $sqlString);
$labelLength = (strlen($sqlString)-strlen($sqlValue));
$tmp = ereg_replace("( )*=( )*", "", trim(substr($sqlString, 0, $labelLength-1)));
$sqlLabel = $tmp;
$sqlArray [$sqlLabel] = trim($sqlValue);
}
return $sqlArray;
}
?>
---------------------------

These are all the files linked together.

Thankx



#2 JasonLewis

JasonLewis
  • Members
  • PipPipPip
  • Advanced Member
  • 3,351 posts
  • LocationVictoria, Australia

Posted 02 October 2006 - 10:02 AM

well there is no function RecordCount in any of those files, after my quick scanning. So it obviously hasnt been made, or it is in a different file. but the error means that it cant find the function RecordCount
Good luck with your coding.
Jason / ProjectFear / Jaysonic

#3 steveclondon

steveclondon
  • Members
  • PipPipPip
  • Advanced Member
  • 161 posts

Posted 02 October 2006 - 10:07 AM

contact who made the script for you and see if you have a missing file

#4 9911782

9911782
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 02 October 2006 - 12:39 PM

well there is no function RecordCount in any of those files, after my quick scanning. So it obviously hasnt been made, or it is in a different file. but the error means that it cant find the function RecordCount


Hi ProjectFear

I have found this function in this file. Here is the code:
----------------------------------------
//==============================================================================================
// CLASS ADORecordSet_empty
//==============================================================================================

/**
* Lightweight recordset when there are no records to be returned
*/
class ADORecordSet_empty
{
var $dataProvider = 'empty';
var $databaseType = false;
var $EOF = true;
var $_numOfRows = 0;
var $fields = false;
var $connection = false;
function RowCount() {return 0;}
function RecordCount() {return 0;} 
function PO_RecordCount(){return 0;}
function Close(){return true;}
function FetchRow() {return false;}
function FieldCount(){ return 0;}
function Init() {}
}

//=====================================
----------------------------------------

#5 JasonLewis

JasonLewis
  • Members
  • PipPipPip
  • Advanced Member
  • 3,351 posts
  • LocationVictoria, Australia

Posted 03 October 2006 - 12:10 PM

the function record count isnt doing anything there. and to my knowledge, the class ADORecordSet_empty isnt defined in the first file. so all RecordCount() in that file would return 0.
Good luck with your coding.
Jason / ProjectFear / Jaysonic

#6 9911782

9911782
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 03 October 2006 - 01:44 PM

How do I solve this problem now?

#7 JasonLewis

JasonLewis
  • Members
  • PipPipPip
  • Advanced Member
  • 3,351 posts
  • LocationVictoria, Australia

Posted 04 October 2006 - 09:25 AM

you need to contact the creator of the script because the function RecordCount() isnt set, even tho its in that file. You are either missing a file or something. check again. because RecordCount() will always return 0. maybe check some other file.
Good luck with your coding.
Jason / ProjectFear / Jaysonic

#8 ponsho

ponsho
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 04 October 2006 - 09:56 AM

That problem regulary appears when you call a class function before calling the class.

Just add this line
$result = new ADORecordSet_empty;

before this
if($result->RecordCount() == 0){
      echo "<meta HTTP-EQUIV='REFRESH' content='0; url=error.php?phrase=".$abbr."'>";
      exit;
   } else{
      echo "<table border='1' bordercolor='#000000'>
               <tr>";


#9 JasonLewis

JasonLewis
  • Members
  • PipPipPip
  • Advanced Member
  • 3,351 posts
  • LocationVictoria, Australia

Posted 05 October 2006 - 07:00 AM

but thats stupid because according to that class RecordCount will always return 0.

function RowCount() {return 0;}

so no matter what he will continue to receive an error, which is really really stupid. so i think a piece of code is missing.
Good luck with your coding.
Jason / ProjectFear / Jaysonic




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users