MySQL error - ?

Problems with the Windows version of XAMPP, questions, comments, and anything related.

MySQL error - ?

Postby OrcaSoul » 07. September 2009 07:31

I'm new to MySQL, so really need help!

The error I get:
Fatal error: Call to undefined method MDB2_Error::fetchRow() in C:\xampp\htdocs\OrcaTools\includes\orcatools.inc on line 193


The query string:
SELECT gv.variety FROM grape_variety gv, wine_variety wv, wine w WHERE w.wine_id = wv.wine_id AND wv.variety_id = gv.variety_id AND w.wine_id = ORDER BY wv.id


This is the function - line 193 is marked with <-:
Code: Select all
// Find the varieties for a wineID
function showVarieties($connection, $wineID)
{
   // Find the varieties of the current wine,
   // and order them by id
   $query = "SELECT gv.variety
             FROM grape_variety gv, wine_variety wv, wine w
             WHERE w.wine_id = wv.wine_id
             AND wv.variety_id = gv.variety_id
             AND w.wine_id = {$wineID}
             ORDER BY wv.id";

   $result = $connection->query($query);
   print $query;

   if (MDB2::isError($result))
      trigger_error($result->getMessage(), E_USER_ERROR);

   $varieties = "";

   // Retrieve and print the varieties
   while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))   // <-<-<-<- line #193
      $varieties .= " {$row["variety"]}";

   return $varieties;
}



So, why isn't this working?
OrcaSoul
 
Posts: 57
Joined: 24. August 2009 23:51

Re: MySQL error - ?

Postby Nobbie » 07. September 2009 10:03

You should read the error message more carefully. The message says, that $result does not know the method fetchRow(). That's not a MySQL Error.

Is that your script? Debug it and find out whats wrong with $result.
Nobbie
 
Posts: 8772
Joined: 09. March 2008 13:04

Re: MySQL error - ?

Postby OrcaSoul » 07. September 2009 20:05

Nobbie wrote:You should read the error message more carefully. The message says, that $result does not know the method fetchRow(). That's not a MySQL Error.

Is that your script? Debug it and find out whats wrong with $result.


Hmmm...OK, I had assumed it was SQL, you are correct, it isn't...but I can't find it defined anywhere in the code I downloaded! :cry:

My apologies for posting - it's been a looooong weekend...and I'm trying to learn everything at once... :roll:
OrcaSoul
 
Posts: 57
Joined: 24. August 2009 23:51

Re: MySQL error - ?

Postby Altrea » 07. September 2009 23:53

Everything to know is in the error_message:

Fatal error: Call to undefined method MDB2_Error::fetchRow() in C:\xampp\htdocs\OrcaTools\includes\orcatools.inc on line 193


File: C:\xampp\htdocs\OrcaTools\includes\orcatools.inc
Line: 193

There must be a function named fetchRow, which the PHP-Interpreter can't find in Class MDB2_Error.

Maybe it's easier for us to see, if you show us the code of line 193
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8294
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: MySQL error - ?

Postby OrcaSoul » 08. September 2009 01:32

It's in the code segment in my original post.

Here it is again:

Code: Select all
    // Find the varieties for a wineID
    function showVarieties($connection, $wineID)
    {
       // Find the varieties of the current wine,
       // and order them by id
       $query = "SELECT gv.variety
                 FROM grape_variety gv, wine_variety wv, wine w
                 WHERE w.wine_id = wv.wine_id
                 AND wv.variety_id = gv.variety_id
                 AND w.wine_id = {$wineID}
                 ORDER BY wv.id";

       $result = $connection->query($query);
       print $query;

       if (MDB2::isError($result))
          trigger_error($result->getMessage(), E_USER_ERROR);

       $varieties = "";

       // Retrieve and print the varieties
       while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))   // <-<-<-<- line #193
          $varieties .= " {$row["variety"]}";

       return $varieties;
    }


I have since found that fetchRow is not part of MDB2...so looking for an "easy" replacement.
OrcaSoul
 
Posts: 57
Joined: 24. August 2009 23:51

Re: MySQL error - ?

Postby Altrea » 08. September 2009 10:22

I don't know anything about the MDB2 class. It's a PEAR class, right?

It seems to be wrong, that your Script tries to call MDB2_Error::fetchRow(), because the MDB_Error class hasn't got a fetchRow method. It's an Error class, so why it should have one? Have you already tried to output your result_set? Maybe your query went wrong.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8294
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: MySQL error - ?

Postby OrcaSoul » 09. September 2009 03:58

OK, I found the reason the code wasn't working...one of those slight-of-hand things you never see even when it hits you in the face:

The use of DB_FETCHMODE_ASSOC was the problem - that is defined in DB.inc, but NOT in MDB2.inc - which uses MDB2_FETCHMODE_ASSOC...

I made that one change, and it ran just as advertised... :roll: :oops:

Aw well, what would life be if we weren't learning something new... :shock:

Thanks for the tips!
OrcaSoul
 
Posts: 57
Joined: 24. August 2009 23:51


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 51 guests