why do i always get this message:Call to undefined function: getmessage()

here is my code:


$db=DB::connect($dsn);
if (DB::isError($db)){
	return $db->getMessage();	
}
$db->setFetchMode(DB_FETCHMODE_ASSOC);
$query = "SELECT  FROM invites"; //i intentionally typed this incorrectly
$result = $db->getAll($query);
if (DB::isError($result)){
	echo $db->getMessage();	
	echo "hello";
} else {
	print_r($result);
}
    return $db->getMessage();	
    echo $db->getMessage();

    It says you have not defined function getMessage()
    in your page

    also it is a Class function
    and the object is $db
    which you probably have created by
    $db = new SomeClass;

    getMessage() has to be a function within SomeClass

      it is created. i checked it. and also i tried to call other functions in that class and it worked fine.

        Call to undefined function: getmessage()

        well, then I do not understand
        but fact is the error says getessage() is not defined
        in this page

        did you spell that function with lower chars somewhere?

        getmessage is not the same as
        getMessage

        did you call them other class functions in this same page
        or in another php page ?

          halojoy wrote:

          getmessage is not the same as
          getMessage

          the function is spelled getMessage.

          halojoy wrote:

          did you call them other class functions in this same page
          or in another php page ?

          in the same page.

          i donot understand too, the last time i tried this codes, the getMessage worked. :queasy:

            i found it! its a syntax error :o

            instead of using

            $result = $db->getAll($query);
            if (DB::isError($result)){
            	echo $db->getMessage();	
            	echo "hello";
            }

            use

            $result = $db->getAll($query);
            if (DB::isError($result)){
            	echo $result->getMessage();	//replace $db with $result
            	echo "hello";
            }
            

            tnx halojoy for the time :p

              $result = $db->getAll($query);
              if (DB::isError($result)){
              	echo $result->getMessage();	//replace $db with $result
              	echo "hello";
              }

              One last thing.
              When you edit or write a post, use the special PHP BBCode tag of this forum.
              Instead of the CODE tag.

              In the tags buttons menu, the 4 buttons to the right are:
              ...... | CODE HTML PHP | QUOTE
              looks like
              .......| # <> php | Q

              will highlight your code in colours like this

              $result = $db->getAll($query);
              if (DB::isError($result)){
              	echo $result->getMessage();	//replace $db with $result
              	echo "hello";
              }

              You should also find in the blue menu 'Thread Tools', above posts:
              Thread Tools Search this Thread Rate Thread Display Modes
              Mark this thread as RESOLVED

                Write a Reply...