Forum Moderators: coopster

Message Too Old, No Replies

Fatal error: non object

No idea how to correct this

         

mcibor

2:18 pm on Aug 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Dear webmasterworld members!

I have a script based on smarty template. After I corrected one mistake in the file chatmsgs.php I got this error:

Fatal error: Call to a member function on a non-object in /usr/home/chatmsgs.php on line 77

I don't know what is the problem, because before and after that line there are many object functions:

[line 75] $query = $db -> Execute("SELECT id FROM chat");
[line 76] $numchat = $query -> RecordCount();
[line 77] $query -> Close();

What the problem may lie?
As I can see it could be anywhere... :(

Help! - I need that chat :)
Michal Cibor

SergUFM

2:51 pm on Aug 23, 2005 (gmt 0)



Seems like you do not have Close() in your class.

dreamcatcher

3:13 pm on Aug 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Or it could be the instance of the class hasn`t been declared properly.

Can we see some more of the code mcibor?

dc

mcibor

11:07 am on Aug 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is the bigger chunk:
session_start();
require_once('libs/Smarty.class.php');

$smarty = new Smarty;
$smarty -> compile_check = true;
$stat = $db -> Execute("SELECT id, rank, lang, seclang, style, graphic FROM players WHERE email='".$_SESSION['email']."' AND pass='".MD5($_SESSION['pass'])."'");
...
$chat = $db -> SelectLimit("SELECT * FROM chat WHERE lang='".$stat -> fields['lang']."' OR lang='".$stat -> fields['seclang']."' AND ownerid=0 OR ownerid=".$stat -> fields['id']." OR senderid=".$stat -> fields['id']." ORDER BY id DESC", 15);
...
while (!$chat -> EOF)
{
$text = wordwrap($chat -> fields['chat'],30,"\n",1);
$arrtext[$i] = $text;
$arrauthor[$i] = $chat -> fields['user'];
$arrsenderid[$i] = $chat -> fields['senderid'];
echo "6d";
$chat -> MoveNext();
echo "6e";
$i = $i + 1;
}
...


I see only: 6d Fatal error....
no 6e.
I'm trying to find where the $db and MoveNext is defined, but it's a hard job :)
Best regards
Michal Cibor

PS. This is chunk from Vallheru code under GNU

mcibor

12:35 pm on Aug 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The problem is with the $db. I couldn't find anything about it! I really don't know where it's defined
The script uses ADODB class. And the worst thing is that I managed to get the same error on the other file and then get rid of it, but it was sth completely different.

Moreover the file chat.php works fine, however the chatmsgs.php which is run in a frame doesn't work. Horrible!

dreamcatcher

6:58 am on Aug 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In your original message you say 'After I corrected one mistake..'.

Is that maybe where the problem lies? Have you retraced your steps? Might be a good idea to start again or try a different piece of code.

dc

mcibor

10:33 am on Aug 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I found the problem, and it was nothing concerned with the code.
The query returned no data and there the problem lied. However I don't know why that is so, because other working scripts have this:

$pass = MD5($_SESSION['pass'];
$stat = $db -> Execute("SELECT id, rank, lang, seclang, style, graphic FROM players WHERE email='".$_SESSION['email']."' AND pass='$pass'");

and it works fine...
I found the problem after remaking everything to plain mysql_fetch_array which returned error - not a valid identifier, and mysql_num_rows was 0. So then I checked the query and the md5 of pass wasn't the same as what's stored in the db.
To say the truth my solution is veery baad! I just got rid of pass in one file (very bad indeed).
So it was more of a logic problem. However it's strange that object fetching didn't raise any errors, just empty object. But maybe that's how adodb fetches data.

Thanks for your fast response!
Michal Cibor