9three Posted June 29, 2009 Share Posted June 29, 2009 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 More sharing options...
WolfRage Posted June 29, 2009 Share Posted June 29, 2009 You did not check for a possible error, which you should. But lets find out what is going on. <?php print_r($get_prod); ?> Link to comment https://forums.phpfreaks.com/topic/164156-solved-odbc-syntax-error/#findComment-865978 Share on other sites More sharing options...
9three Posted June 29, 2009 Author Share Posted June 29, 2009 I figured it out. I needed to remove the single quotes around the variables columnSort and viewSort Thank you. Link to comment https://forums.phpfreaks.com/topic/164156-solved-odbc-syntax-error/#findComment-865979 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.