Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Strange Code Error


KennethS

Recommended Posts

Posted

In installing the following code and I keep getting an error about SQL syntax. Ive changed it almost every way I know possible without much luck. If anyone knows the error Ive made here and how to fix please post it here. If you need more information I will glady post it. The code is pulled from "product_info.php" from MS2.2.

 

Error:

This product contains the following items:1064 - You have an error in your SQL syntax near 'and language_id = '1'' at line 7
SELECT pd.products_name, pb.*, p.products_bundle, p.products_id, p.products_price FROM products p INNER JOIN products_description pd ON p.products_id=pd.products_id INNER JOIN products_bundles pb ON pb.subproduct_id=pd.products_id WHERE pb.bundle_id = and language_id = '1'
[TEP STOP]

 

Code:

<?php     

   if ($product_info['products_bundle'] == "yes") {

  	 $products_bundle = $product_info['products_bundle'];

  	 echo "This product contains the following items:";

	 $bundle_query = tep_db_query("	SELECT pd.products_name, pb.*, p.products_bundle, p.products_id, p.products_price

        	 FROM products p 

        	 INNER JOIN products_description pd

            ON p.products_id=pd.products_id

        	 INNER JOIN products_bundles pb

            ON pb.subproduct_id=pd.products_id 

        	 WHERE pb.bundle_id = " . tep_get_prid($products_id) . " and language_id = '" . (int)$languages_id . "'");

	 while ($bundle_data = tep_db_fetch_array($bundle_query)) {

   if ($bundle_data['products_bundle'] == "yes") {

  	 // uncomment the following line to display subproduct qty 

                             // echo "<br>» <b>" . $bundle_data['subproduct_qty'] . " x " . $bundle_data['products_name'] . "</b>";

  	 echo "<br>» <b> " . $bundle_data['products_name'] . "</b>";

  	 $bundle_query_nested = tep_db_query("	SELECT pd.products_name, pb.*, p.products_bundle, p.products_id, p.products_price

        	 FROM products p 

        	 INNER JOIN products_description pd

            ON p.products_id=pd.products_id

        	 INNER JOIN products_bundles pb

            ON pb.subproduct_id=pd.products_id 

        	 WHERE pb.bundle_id = " . $bundle_data['products_id'] . " and language_id = '" . (int)$languages_id . "'");

  	 while ($bundle_data_nested = tep_db_fetch_array($bundle_query_nested)) {

        	 // uncomment the following line to display subproduct qty 

                                   // echo "<br><i>     " . $bundle_data_nested['subproduct_qty'] . " x " . $bundle_data_nested['products_name'] . "</i>";

     echo "<br><i>     " . $bundle_data_nested['products_name'] . "</i>";

     $bundle_sum += $bundle_data_nested['products_price']*$bundle_data_nested['subproduct_qty'];

  	 }

   } else {

  	 // uncomment the following line to display subproduct qty 

                             // echo "<br>» <b>" . $bundle_data['subproduct_qty'] . " x " . $bundle_data['products_name'] . "</b>";

  	 echo "<br>» <b> " . $bundle_data['products_name'] . "</b>";

  	 $bundle_sum += $bundle_data['products_price']*$bundle_data['subproduct_qty'];

   }

	 }

	 $bundle_saving = $bundle_sum - $product_info['products_price'];

	 $bundle_sum = $currencies->display_price($bundle_sum, tep_get_tax_rate($product_info['products_tax_class_id']));

	 $bundle_saving =  $currencies->display_price($bundle_saving, tep_get_tax_rate($product_info['products_tax_class_id']));

                 // comment out the following line to hide the "saving" text

	 echo "<p><b>Cost of separate parts: " . $bundle_sum . '<br><font color="red">You save ' . $bundle_saving . '</font></b>';

   } 

   ?>

 

Thanks,

Kenneth S.

Kenneth S

--------------

Customer "Are you a real programmer?"

Me "No, but I did stay at a Holiday Inn Express last night"

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...