Jump to content

php return sql query return 0


abdelelbouhy

Recommended Posts

hello guys,this function just to get products_id function getProductId( $model, $importFrom = '' ) //retrun product id{ if( empty( $model ) ) { return 0; } if($importFrom == 'Play'){ $sql_where = " play_sku = '$model'"; }else{ $sql_where = " products_model = '$model'"; } $select_orderid_query_raw = "SELECT * FROM " . TABLE_PRODUCTS . " WHERE " . $sql_where; $select_orderid_query = tep_db_query($select_orderid_query_raw); $productsId = 0; while ( $orderId = tep_db_fetch_array($select_orderid_query) ) { $productsId = $orderId['products_id']; } return $productsId;}what happend is it return always 0 even that play_sku exists but when i hard code the $model to 5060164670018 which is the same if i pass it the function it return the right result$model i'm getting from file i read it with fgetcsv then i used the array to get the value of $model which is $arr[4] the $model field in sql is VARCHAR could it be because i'm looking for a number and the $model is passed as a stringplease help

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...