Jump to content

[SOLVED] ODBC Syntax error?


9three

Recommended Posts

Hey,

 

I'm getting this error:

Warning: odbc_fetch_array(): supplied argument is not a valid ODBC result resource in C:\Users\Public\Desktop\Server\www\web\system_files\sql_class\_customer_purchase_history.class.php on line 34

 

Although the syntax looks correct. Could someone else lend a pair of eyes please? :)

 

function get_prod_from_sql($New_ship = '', $columnSort = 'item_desc', $viewSort = 'ASC') 
{
  global $cust_account, $shipping_session, $shipping_id;
  $conn = odbc_connect(PROPHET_DATA_SOURCE, PROPHET_USER, PROPHET_PASSW);
  if($shipping_session > 0 || $New_ship > 0 ) 
  {
    $prod_query = "SELECT * FROM jbi_web_cust_purch_hist 
                         WHERE customer_id = '" .(int)$cust_account. "' 
                         AND ship_to_id = '" .$shipping_session. "' 
                         ORDER BY '".$columnSort."' '".$viewSort."'";
  }
  else
  {
    if ($New_ship == "Show_all")
    {
      $prod_query = "SELECT * FROM jbi_web_cust_purch_hist 
                           WHERE customer_id = '" .(int)$cust_account. "' 
                           ORDER BY '".$columnSort."' '".$viewSort."'";
    }
    else
    {
      $prod_query = "SELECT * FROM jbi_web_cust_purch_hist 
                           WHERE customer_id ='" .(int)$cust_account. "' 
                           AND ship_to_id ='".$shipping_id."' 
                           ORDER BY '".$columnSort."' '".$viewSort."'";
    }
  }
  $prod_conn = odbc_exec($conn, $prod_query);
  while($favorites = odbc_fetch_array($prod_conn))
  {
    $part_number = $favorites['part_no'];
    $qty = (int)$favorites['qty_shipped'];
    $item_desc = $favorites['item_desc'];
    $ext_price = $favorites['ext_price'];
    $get_prod = db_query("SELECT products_id, short_code FROM " . TABLE_PRODUCTS . " WHERE part_number = '" . $part_number . "'");
    $prod_res = db_fetch_array($get_prod);
    $this->contents[$favorites['part_no']] = array('qty' => $qty, 'products_id' => $prod_res['products_id'], 'prod_name' => $prod_res['short_code'], 'ext_price' => $ext_price, 'products_name' =>$item_desc);//adding element to the array contents
  }
}

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/164156-solved-odbc-syntax-error/
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.