Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 16th, 2007, 12:32 PM
Registered User
 
Join Date: Oct 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default infinite loop

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?

Code:
$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); 

     }


Reply With Quote
  #2 (permalink)  
Old December 21st, 2007, 10:44 AM
Registered User
 
Join Date: Nov 2007
Location: , , India.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to v08i
Default

Hi,

change the = in this line to == (comparison operator)
 ==> if($tuple["usp_tracking_number"]=$tn)

currently it is assigning the value of $tn to $tuple["usp_tracking_number"] and it is being evaluated as true each time.
Therefore going in a infinite loop

Regards
Vijay

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem of infinite loop sarah lee ASP.NET 1.0 and 1.1 Basics 19 December 14th, 2006 09:26 AM
problem getting out of infinite loop and incremtin method VB How-To 0 April 28th, 2006 11:45 PM
Infinite timer? acdsky VBScript 1 June 17th, 2004 02:59 PM
How to Write a Infinite Loop Detection jtdang77 Classic ASP Professional 1 October 15th, 2003 03:44 AM
Infinite Loop Detection jtdang77 Classic ASP Basics 0 October 14th, 2003 05:32 PM



All times are GMT -4. The time now is 12:01 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.