Hi,
I am working on porting the Fedex Freight Module from OsCommerce. I am getting stuck on one section of code that queries the products table for several fields that have been added (most importantly freight class). But for some reason I am not getting the data back or not processes the query results correctly:
Excerpt of the problem area:
Code:
//Get the shopping cart contents
$products = $_SESSION['cart']->get_products();
$url_attr = '';
$x = 1;
$fxf_urls = array();
$n = sizeof($products);
for ($i=0; $i<$n; $i++) {
$prod_query = $db->Execute("select products_fxf_class, products_fxf_desc,
products_fxf_nmfc, products_fxf_haz, products_fxf_freezable FROM " .
TABLE_PRODUCTS . " WHERE products_id = '".$products[$i]['id']."'");
// this doesn't work
// $prod_info = array();
// while (!$pro_query->EOF) {
// $prod_info[] = $pro_query->fields['products_id'];
// $pro_query->MoveNext();
// }
// this query doesn't work and throws a mysql error
$prod_info = $db->Execute($prod_query);
// this is the original code
// $prod_info = tep_db_fetch_array($prod_query);
// prep XML request class, weight, pcs, descr, nmfc, haz, freezable
$url_attr .= '&as_class' . $x . '=' . $prod_info['products_fxf_class'];
$url_attr .= '&as_weight' . $x . '=' . $products[$i]['quantity'] * (int)$products[$i]['weight'];
$url_attr .= '&as_pcs' . $x . '=' . $products[$i]['quantity'];
I tested the query in phpMyAdmin, and it seems correct. But I am having trouble getting the data from $prod_query...
I hope someone can show what I am doing wrong. I am very close to finishing this, and the other areas of the port seem to be working.
Bookmarks