Jump to content

fatal error in php


9911782

Recommended Posts

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

Link to comment
Share on other sites

[quote author=ProjectFear link=topic=110216.msg445112#msg445112 date=1159783327]
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
[/quote]

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() {}
}

//=====================================
----------------------------------------
Link to comment
Share on other sites

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

Just add this line
[code]
$result = new ADORecordSet_empty;
[/code]

before this
[code]
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>";
[/code]
Link to comment
Share on other sites

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.