Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1
    Join Date
    Feb 2009
    Posts
    120
    Plugin Contributions
    0

    help question SQL Table Error (table doesn't exist?)

    Hello,

    I'm trying to programme a '3 for 2' module and keep getting this error message:

    Code:
    1146 Table 'xkwies_handcrafteduk.products_3_for_2_flags' doesn't exist
    in:
    [ select products_id from products_3_for_2_flags where products_id = 882]
    Is this trying to say I haven't got the table 'products_3_for_2_flags' in my database? Because, I have! Any ideas what's going wrong please? :)

    Many thanks,

    Gary

  2. #2
    Join Date
    Feb 2009
    Posts
    120
    Plugin Contributions
    0

    Default Re: SQL Table Error (table doesn't exist?)

    I should also say that product id 882 is also in the table so not sure why it can't find it?

    I tried flushing the table too but that didn't seem to work either.

  3. #3
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: SQL Table Error (table doesn't exist?)

    Quote Originally Posted by plymgary1 View Post
    keep getting this error message:

    Table 'xkwies_handcrafteduk.products_3_for_2_flags' doesn't exist
    < snip >
    Is this trying to say I haven't got the table 'products_3_for_2_flags' in my database?
    No. It is saying the table 'xkwies_handcrafteduk.products_3_for_2_flags' doesn't exist.

    Quote Originally Posted by plymgary1 View Post
    Because, I have! Any ideas what's going wrong please? :)
    The table 'xkwies_handcrafteduk.products_3_for_2_flags' doesn't exist. We have no way to know if table 'products_3_for_2_flags' exists or not. The error message says nothing about this table.

    Cheers
    Rod

  4. #4
    Join Date
    Feb 2009
    Posts
    120
    Plugin Contributions
    0

    Default Re: SQL Table Error (table doesn't exist?)

    Quote Originally Posted by RodG View Post
    No. It is saying the table 'xkwies_handcrafteduk.products_3_for_2_flags' doesn't exist.



    The table 'xkwies_handcrafteduk.products_3_for_2_flags' doesn't exist. We have no way to know if table 'products_3_for_2_flags' exists or not. The error message says nothing about this table.

    Cheers
    Rod
    Thanks for your reply. :)

    Oh, I thought xkwies_handcrafteduk. was the name of the DB it was trying to access and products_3_for_2_flags was the table?

    Am I wrong? If so, I'll have to find a way around it. :)

  5. #5
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: SQL Table Error (table doesn't exist?)

    Quote Originally Posted by plymgary1 View Post
    Thanks for your reply. :)

    Oh, I thought xkwies_handcrafteduk. was the name of the DB it was trying to access and products_3_for_2_flags was the table?

    Am I wrong? If so, I'll have to find a way around it. :)
    Not entirely wrong, but the quotes make a huge difference in this case. In other words, 'xkwies_handcrafteduk.products_3_for_2_flags' (with quotes) is looking for a table of this name in the currently opened database.

    If you remove the quotes it will indeed be looking for a table named 'products_3_for_2_flags' in the 'xkwies_handcrafteduk' database.

    Does this make it clearer?

    Cheers
    Rod

  6. #6
    Join Date
    Jan 2004
    Posts
    66,374
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: SQL Table Error (table doesn't exist?)

    Quote Originally Posted by plymgary1 View Post
    Thanks for your reply. :)

    Oh, I thought xkwies_handcrafteduk. was the name of the DB it was trying to access and products_3_for_2_flags was the table?

    Am I wrong? If so, I'll have to find a way around it. :)
    plymgary1, actually you are indeed correct.

    RodG missed the fact that the SQL query gives away the fact that the query is indeed looking in the xkwies_handcrafteduk database for the table named products_3_for_2_flags.

    So, instead, you probably have a prefix problem.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  7. #7
    Join Date
    Feb 2009
    Posts
    120
    Plugin Contributions
    0

    Default Re: SQL Table Error (table doesn't exist?)

    Thanks for the replies. :)

    I bet it's something really easy to fix but I just have no idea! Would someone mind taking a look at the code below from modules/order_total/ and see what the problem might be please?

    Code:
    <?php
    
    
    
      class ot_3_for_2_discount_flags {
    
        var $title, $output;
        var $explanation; 
    
        function ot_3_for_2_discount_flags() {
          $this->code = 'ot_3_for_2_discount_flags';
          $this->title = MODULE_ORDER_TOTAL_3_FOR_2_DISCOUNT_FLAGS_TITLE;
          $this->description = MODULE_ORDER_TOTAL_3_FOR_2_DISCOUNT_FLAGS_DESCRIPTION;
          $this->sort_order = MODULE_ORDER_TOTAL_3_FOR_2_DISCOUNT_FLAGS_SORT_ORDER;
          $this->output = array();
        }
    
    	function check_product($pid) {
    		global $db;
    		
    		$sql_chk = " select products_id from products_3_for_2_flags where products_id = ". (int)$pid;
    		$rs_chk = $db->Execute($sql_chk);
    		
    		if ($rs_chk->EOF) {
    			return false;
    		}
    		else {
    			return true;
    		}
    	}
    	
        function print_amount($amount) {
          global $db, $order, $currencies;
          return  $currencies->format($amount, true, $order->info['currency'], $order->info['currency_value']);
        }
    
        function get_order_total() {
           global  $order;
           $order_total_tax = $order->info['tax'];
           $order_total = $order->info['total'];
    
           $order_total -= $order->info['shipping_cost'];
           $order_total -= $order->info['tax'];
           $orderTotalFull = $order_total;
           $order_total = array('totalFull'=>$orderTotalFull, 'total'=>$order_total, 'tax'=>$order_total_tax);
           return $order_total;
        }
    
        function process() {
           global $db, $order, $currencies;
           $od_amount = $this->calculate_deductions();
           if ($od_amount['total'] > 0) {
             $order->info['total'] = $order->info['total'] - $od_amount['total'];
             $this->title = '<a href="javascript:alert(\'' . $this->explanation . '\');">' . $this->title . '</a>'; 
             $this->output[] = array('title' => $this->title . ':',
             'text' => '-' . $currencies->format($od_amount['total'], true, $order->info['currency'], $order->info['currency_value']),
             'value' => $od_amount['total']);
           }
        }
    
        function calculate_deductions() {
           global $db, $order, $currencies;
    	   
           $od_amount = array();
           $od_amount['tax'] = 0;
    
           $products = $_SESSION['cart']->get_products();
    
           $prod_list = array();
           $prod_list_price = array();
           $prod_list_back = array(); 
    	   
           $all_items = 0;
           $all_items_price = 0;
    	   
    	   $disc_amount = 0;
    
           for ($i=0, $n=sizeof($products); $i<$n; $i++) {
    	   
    	   	if ($this->check_product($products[$i]['id'])) {
    		
    	          $price = $products[$i]['final_price'];
    	          $quantity = $products[$i]['quantity'];
    	
    			  //$disc_amount += $this->get_disc_amount($quantity, $price);
    			  
    	          //$prod_list_back[$products[$i]['id']] = &$products[$i];
    	          //$prod_list[$products[$i]['id']] += $quantity;
    	          //$prod_list_price[$products[$i]['id']] += ($price * $quantity);
    	
    	          $all_items += $quantity;
    	          //$all_items_price += ($price * $quantity);
    		}	  
    		
           }
    
    		$disc_amount += $this->get_disc_amount($all_items, $price);
    		  
           $this->explanation = YOUR_CURRENT_3_FOR_2_DISCOUNT_FLAGS . "\\n" . "\\n"; 
           $this->explanation .= "\\n\\n" . TOTAL_DISCOUNT . $this->print_amount($disc_amount); 
    	   $od_amount['total'] = round($disc_amount, 2); 
           return $od_amount;
       }
    
       function get_disc_amount($count,$price) {
          $disc_amount = 0;
    	  $new_count = $count - ($count%3);
    //	  if (($count % 3) == 0) {
    	  	$disc_amount = ($new_count/3) * 3;
    //	  }	
          return $disc_amount; 
       } 
    
    
       function pre_confirmation_check($order_total) {
          $od_amount = $this->calculate_deductions();
          return $od_amount['total'] + $od_amount['tax'];
        }
    
        function credit_selection() {
          return $selection;
        }
    
        function collect_posts() {
        }
    
        function update_credit_account($i) {
        }
    
        function apply_credit() {
        }
    
        function check() {
          global $db;
          if (!isset($this->_check)) {
            $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_3_FOR_2_DISCOUNT_FLAGS_STATUS'");
            $this->_check = $check_query->RecordCount();
          }
          return $this->_check;
        }
    
        function keys() {
          return array('MODULE_ORDER_TOTAL_3_FOR_2_DISCOUNT_FLAGS_STATUS', 'MODULE_ORDER_TOTAL_3_FOR_2_DISCOUNT_FLAGS_SORT_ORDER');
        }
    
        function install() {
          global $db;
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('&copy; Gary<br /><div><a href=\"http://www.mywebsite.com\" target=\"_blank\">Website</a></div><br />This module is installed', 'MODULE_ORDER_TOTAL_3_FOR_2_DISCOUNT_FLAGS_STATUS', 'true', '', '6', '1','zen_cfg_select_option(array(\'true\'), ', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_3_FOR_2_DISCOUNT_FLAGS_SORT_ORDER', '299', 'Sort order of display.', '6', '2', now())");
        }
    
        function remove() {
          global $db;
          $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
        }
    
      }
    
    ?>
    The table products_3_for_2_flags is there too. Here's a screen cap :)



    Any idea? Please?

  8. #8
    Join Date
    Jan 2004
    Posts
    66,374
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: SQL Table Error (table doesn't exist?)

    Sounds like your configure.php is pointing to a different database than the one you're looking at in phpMyAdmin
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  9. #9
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: SQL Table Error (table doesn't exist?)

    Quote Originally Posted by DrByte View Post
    Sounds like your configure.php is pointing to a different database than the one you're looking at in phpMyAdmin
    My thoughts exactly.

    I can't think of any other explanation. Pity the top half of the screenshot provided was missing, else we'd know for sure :)

    Cheers
    Rod

  10. #10
    Join Date
    Feb 2009
    Posts
    120
    Plugin Contributions
    0

    Default Re: SQL Table Error (table doesn't exist?)

    Sorry for the delay getting back.

    I'm not sure the problem is with configure.php? There's no other connectivity problem with the db.

    Here's a screenshot where you can see the table name. :)

    [scr]http://www.handcrafteduk.com/screen2.jpg[/scr]

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v139h SQL Error 1146 Table TABLE_CUSTOMERS_ADMIN_NOTES doesn't exist
    By utefan in forum General Questions
    Replies: 4
    Last Post: 3 Mar 2016, 07:45 PM
  2. v151 upgrading error 1146 table doesn't exist
    By scottrdj in forum Upgrading to 1.5.x
    Replies: 4
    Last Post: 31 Dec 2012, 03:05 PM
  3. 1146 Table 'XXXX.zen_configuration' doesn't exist in: [db_cache table]
    By CheapStairParts in forum General Questions
    Replies: 1
    Last Post: 4 Jan 2011, 12:39 AM
  4. table error please help: "table 'sessions' doesn't exist"
    By ebydrc in forum General Questions
    Replies: 3
    Last Post: 6 Apr 2008, 06:13 AM
  5. 1146 Table error zenconfiguration doesn't exist
    By gayelston in forum Installing on a Linux/Unix Server
    Replies: 6
    Last Post: 1 Dec 2007, 10:26 PM

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