Jump to content

Archived

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

9911782

fatal error in php

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

Share this post


Link to post
Share on other sites
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

Share this post


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

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

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.