Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2007

    Unanswered: Call to a member function fetch_array() on a non-object

    Edited to add: when I try to display this page the URL reads: [http://php2/200508/bronwyn/PhpClass/...t.php?Book_ID= ] so I think my variable $bid has a problem i.e. I haven't declared this properly. Is $bid the non-object?

    So, this is my problem. My sql query works on its own. I'm not clear on what the non-object is, does fetch_array() have to be declared somewhere else?
    The line the error refers to is if($row=$table->fetch_array()){
    Using PHP 5.0 MySql client version 5.0.45

    any feedback appreciated,

    PHP Code:
    $productid $_REQUEST['Book_ID']; //customer has clicked product with id 2 for ex.
    function fetchProduct($bid){
    $bk = new Books();
    $table $bk->getData("select * from books where Book_ID=".$bid);
    $pname $row['Title'];
    $pdesc $row['Author'];
    $pprice $row['BookPrice'];
    Last edited by bronisaurus; 07-23-08 at 09:02.

  2. #2
    Join Date
    Jul 2007
    Okay my sql was right and I didn't change anything and it started working. It's good that it's working but I don't have a clue how it went from not working to working

  3. #3
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    it could be that an object/class had been changed but the webserver was using an old compiled copy of the class, when you assigned a value to the new member in the class the compiler crapped out because it didn't know about the new version of the class.
    Ive had numerous problems with classes being out of step. dunno where the problme lies, whjether its a php problem or server problem, bu tit does happen. I often find he only way to demonstrate/clear the fault is to restart the server, during development I put a class property of version, or a time stamp so I can see if the server is using the current generation of code

    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Jul 2007
    Ah thanks, it might have been after a restart of the server that it began to work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts