Copyright © 2005-2008 Andrea Tincani

AndreaPHP | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Syntax Highlight)Next Topic (Seperating each line of a textbox) New Topic New Poll Post Reply
AndreaPHP Forum : PHP General : Problem with a class.. again!!
Poster Message
neutrall
Level: Scholar


Registered: 28-03-2004
Posts: 43

icon Problem with a class.. again!!

Hi, workig out some bugs out of my admisnistration menu. This time, it's giving me problem with a method from the MySQL class (Uploaded in the download section).

This is the function calling to the class :


    <?php function New_Forest_Creature($name$strenght$defence$goldfound=0$weaponfound=0$defencefound=0$weaponid=0$defenceid=0$questid=0$level=0) {
     
        
$sql "INSERT INTO Forest_Creature SET
/* ADD NEW RECORD HERE */

            Level=$level"
;
        
$this->db->query($sql);    
        if (
$this->db->isError()) {
            return 
FALSE;
        } else {
            
$this->Id $this->db->insertID();
            return 
TRUE;
        }
    } 
?>



now my problem if the following line :

<?php 
$this
->Id $this->db->insertID();
?>


I kept getting the error :
Fatal error: Call to undefined method MySQL::insertID() in J:\WEBSITE\WWW\class\forest_creature.php on line 242


Now I've triple check the MySQL class, and insertID is defined.... Any idea?


[Edited by neutrall on 12-05-2005 at 10:36 AM GMT]

[Edited by neutrall on 12-05-2005 at 10:37 AM GMT]

____________________________
A Stick give a wise man something to think about... and a fool, something to put in is mouth.

05-05-2005 at 05:00 PM
View Profile Send Email to User Show All Posts Visit Homepage ICQ | Quote Reply
admin
Level: Administrator


Registered: 04-04-2002
Posts: 35

icon Re: Problem with a class.. again!!

I guess this->db is a MySQL class but insertID is as method of another class (MySQLResult)

you should use a $result to assign it the result of the query, this will be of type MySQLResult and then you'll have your insertID method on $result


<?
$result
=$this->db->query($sql);
if (
$this->db->isError()) {
return 
FALSE;
} else {
$this->Id $result->insertID();
return 
TRUE;
}
?>



I haven't tested it but tell me if it works...

[Edited by admin on 12-05-2005 at 12:00 PM GMT]

____________________________
AndreaVB

05-05-2005 at 05:24 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
neutrall
Level: Scholar


Registered: 28-03-2004
Posts: 43

icon Re: Problem with a class.. again!!

     You know.... Maybe there's not a lot of active people on the PHP section, but those who are..... my god are they ever good!!!!


(If this didn't answer you question, well... yes! it work!!!)

I was starting to wonder if they was something wrong with the class!

[Edited by neutrall on 05-05-2005 at 10:43 PM GMT]

____________________________
A Stick give a wise man something to think about... and a fool, something to put in is mouth.

06-05-2005 at 03:42 AM
View Profile Send Email to User Show All Posts Visit Homepage ICQ | Quote Reply
AndreaPHP Forum : PHP General : Problem with a class.. again!!
Previous Topic (Syntax Highlight)Next Topic (Seperating each line of a textbox) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: AndreaVB

Copyright © 2005-2008 Andrea Tincani

Powered by: tForum tForum Edition b0.92p1
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team.