Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2008
    Location
    Peoria, IL USA
    Posts
    25
    Plugin Contributions
    0

    Default Accessing a database table

    Hi,
    I have downloaded the latest Zen cart and installed it okay.
    Everything seems to be working well.

    Now I have added a table to the database using phpMyAdmin.

    When I try to access this table I get the error:
    Call to a member function on a non-object

    Can someone tell me what may be wrong?
    Thanks,
    Dave

  2. #2
    Join Date
    Feb 2006
    Location
    Chicago
    Posts
    1,162
    Plugin Contributions
    0

    Default Re: Accessing a database table

    Error string seems to be the php coding problem
    Can you post the code here you tried to read the table?
    May be you have forgotten to include some file(s)?
    Tutorials on Zen Cart
    http://tutorials.zen-cart.com/index.php
    ---------------
    advanced.programmer at gmail dot com
    In love with Zen Cart!!

  3. #3
    Join Date
    Feb 2008
    Location
    Peoria, IL USA
    Posts
    25
    Plugin Contributions
    0

    Default Re: Accessing a database table

    Quote Originally Posted by superprg View Post
    Error string seems to be the php coding problem
    Can you post the code here you tried to read the table?
    May be you have forgotten to include some file(s)?
    Here is the code:

    Code:
         $licences = array(); 
          $this->licences_html = $this->licences_text = ''; 
          for ($i=0, $n=sizeof($this->products); $i<$n; $i++) { 
              $db->Execute('UPDATE products_licences SET orders_id='.$zf_insert_id 
                           . ' WHERE products_id='.(int)$this->products[$i]['id']
                               . ' AND orders_id IS NULL' 
                               . ' LIMIT '.$this->products[$i]['qty'] 
                           ); 
              $dbres = $db->Execute('SELECT licences_code FROM products_licences' 
                           . ' WHERE products_id='.(int)$this->products[$i]['id'] 
                               . ' AND orders_id='.$zf_insert_id 
                           ); 
            while(!$dbres->EOF) { 
                $this->licences_html .= '<p>'.(int)$this->products[$i]['id'].':<br><span class=licences_code>'.$dbres->fields['licences_code'].'</span></p>';		
                $this->licences_text .= "Here is the Serial Number for your program "."\n".$this->products[$i]['name'].":\n".$dbres->fields['licences_code']."\n\n"; 
                $licences[(int)$this->products[$i]['id']][] = $dbres->fields['licences_code']; 
                $dbres->MoveNext(); 
            } 
          }
    I am getting the error on this line:
    $db->Execute('UPDATE products_licences SET orders_id='.$zf_insert_id

    Thanks,
    Dave

  4. #4
    Join Date
    Feb 2006
    Location
    Chicago
    Posts
    1,162
    Plugin Contributions
    0

    Default Re: Accessing a database table

    Fine, where did you declare $db in the code?
    Tutorials on Zen Cart
    http://tutorials.zen-cart.com/index.php
    ---------------
    advanced.programmer at gmail dot com
    In love with Zen Cart!!

  5. #5
    Join Date
    Feb 2008
    Location
    Peoria, IL USA
    Posts
    25
    Plugin Contributions
    0

    Default Re: Accessing a database table

    Quote Originally Posted by superprg View Post
    Fine, where did you declare $db in the code?
    Well, that was it. I did not declare $db.
    It is working well now.

    Thank you,
    Dave

 

 

Similar Threads

  1. 1146 Table ... doesn't exist when accessing Admin
    By LilleyPadGifts in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 19 Jan 2009, 12:21 AM
  2. Accessing a table from another site
    By BlueCrystal in forum General Questions
    Replies: 2
    Last Post: 30 May 2008, 05:48 AM
  3. Exporting Customer Database and accessing passwords
    By Orders in forum Managing Customers and Orders
    Replies: 6
    Last Post: 21 Aug 2006, 10:04 PM
  4. Accessing the database
    By Ruby in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 25 May 2006, 12:03 AM
  5. Multiple Zen Carts accessing one database
    By mdmerrell in forum General Questions
    Replies: 2
    Last Post: 15 May 2006, 06:28 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR