Jump to content
Sign in to follow this  
abdelelbouhy

php return sql query return 0

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

Share this post


Link to post
Share on other sites

It will return 0 if the model is empty or the query doesn't return any records. You'll need to add debugging statements there to figure out which one of those is the case.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...