smilesmita Posted November 16, 2007 Share Posted November 16, 2007 i have this while loop which when the $tn doesnt match with the tracking number in the tuple array it shud update the table else it shud insert.insert is working fine but when it the tn matches with tracking number ..it just is going in an infinite loop.i tried printing the update queries and they just get printed infinitely....any ideas where i am going wrong? $rd = $db->Query("SELECT usp_tracking_number from am_ups_shipment_package_reference"); $i = 0; while ($flag=true && $i < $rd->Row_Count()){ $tuple=$rd->Fetch_Row($i); if($tuple["usp_tracking_number"]=$tn){ $flag=false; if(Is_Array($shipment)){ $query = "UPDATE am_ups_shipment SET us_delivery_date=to_timestamp($shipment[us_delivery_date]),us_delivery_time=$shipment[us_delivery_time], us_billto_option=$shipment[us_billto_option],us_billto_number='$shipment[us_billto_number]', us_shipper_id='$shipment[us_shipper_id]' WHERE us_id in (select us_id from am_ups_shipment_package_reference where usp_tracking_number='$tn');"; $rn = $db->Query($query); } $query1="UPDATE am_ups_shipment_location SET usl_ups_id='$shipmentt[us_shipper_id]' WHERE usl_id='$shipment[us_shipper_id]';"; $rn1 = $db->Query($query1); $ship_ref1=Array(); if(Is_Array($ship_ref)){ $ship_ref1["usr_code"]=$ship_ref[0]["usr_code"]; $ship_ref1["usr_value"]=$ship_ref[0]["usr_value"]; $query2 = "UPDATE am_ups_shipment_reference SET usr_code='$ship_ref1[usr_code]',usr_value='$ship_ref1[usr_value]' WHERE us_id in (select us_id from am_ups_shipment_package_reference where usp_tracking_number='$tn');"; $rnn=$db->Query($query2); } if(Is_Array($ship_ref_pack)){ $query3 = "UPDATE am_ups_shipment_package_reference SET uspr_code='$ship_ref_pack[uspr_code]',uspr_value='$ship_ref_pack[uspr_value]' WHERE us_id in (select us_id from am_ups_shipment_package_reference where usp_tracking_number='$tn');"; $rn2 = $db->Query($query3); } } } $i++; echo "insert"; $this->Write_UPS($shipment,$ship_ref,$ship_ref_pack,$sp); } Quote Link to comment Share on other sites More sharing options...
Barand Posted November 16, 2007 Share Posted November 16, 2007 if($tuple["usp_tracking_number"] == $tn){ The equality operator is "==", not "=" Quote Link to comment Share on other sites More sharing options...
smilesmita Posted November 16, 2007 Author Share Posted November 16, 2007 i tried that..it is still going into infinite loop??? Quote Link to comment Share on other sites More sharing options...
Barand Posted November 16, 2007 Share Posted November 16, 2007 Check your { ... } the $i++ is outside the while loop. Quote Link to comment Share on other sites More sharing options...
smilesmita Posted November 16, 2007 Author Share Posted November 16, 2007 if i place i++ inside the while loop then it executes the update queries and also the insert one which falls out side the loop..i just wnat it to execute update querye once the tn matches and if it doesnt then it shud go for the insert one...? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.