I am bit confused too. But if i understood it right:

why dont you try to use "if" to check if the field has a value returned or not. if not returned do not include it in the query.

try to make your query dynamically something like: (Please be carefull with " and ', i am not right here)

$query_rsusers1 = "UPDATE users SET transStatus = '".$transtatusField. "',";

if ( isset ( $transIDField ) )
   {
   $query_rsusers1 .= 'transID = '".$transIDField.',"';
   }

..........................................................

Hope that helps, but sorry if i am wrong or if i understood it wrong.

    Thanks,

    I think you understood right actually.

    But let me just make sure if you don't mind

    I am trying to say (in plain english) EITHER:

    If '".$transtatusField."' = empty DO NOT overwrite previous value in the database

    OR

    if '".$futurePaystatusChange."' = NOT empty DO NOT overwrite previous ".$transtatusField."' value in the database

    I just don't know about dynamic query and how to phrase this properly..

    Is what you suggested going towards what I describe above?

    many thanks,
    vinny

      yeap thats what it does. because if you dont include it in the update query it wont update that value and leaves the old value there.

      when i say dynamic query its just you build your query depending on conditions, you use string concat "." (dot) and build up your query.

      If you want the actual query, i am at work so i might help you when i get home.

      ta.

        Thanks a lot,

        I'll play with it and try to write it ok.
        I'm not against making the effort to learn of course.

        However, I'd be very grateful if you could post the full code when you have time later so I can see where I may go wrong and use it as an example for future similar issues if you don't mind.

        Thanks again.

          $query_rsusers1 = "UPDATE users SET transStatus = '".$transtatusField."'";
          if($transIDField){ $query_rsusers1 .= ", transID = '".$transIDField."'"; }
          if($cartID){ $query_rsusers1 .= ", cartID = '".$cartID."'"; }
          if($amountField){ $query_rsusers1 .= ", amount = '".$amountField."'"; }
          if($futurePayIDField){ $query_rsusers1 .= ", futurepayID = '".$futurePayIDField."'"; }
          if($futurePaystatusChange){ $query_rsusers1 .= ", FuturePayStatusChange = '".$futurePaystatusChange."'"; }
          if($PaymentIDField){ $query_rsusers1 .= ", ut1 = '".$PaymentIDField."'"; }
          $query_rsuesers1 .= "  WHERE Uid = '".$cartID."' OR futurepayID = '".$futurePayIDField."'";

          I believe that is what he was talking about.

            humm..

            That did not work.

            what that did is upon cancellation, the ENTIRE column FuturePayStatusChange (all rows) was updated, regardless of the "where futurepayID = '".$futurePayIDField."'";" which it used to do

            And

            And the ENTIRE column FuturePayStatusChange was overwritten (all rows) with NULL as of copurse this value does not exist upon cancelation.

              just a quick confirmation:

              if approved:
              you get all the fields and you use cartID to update the data.

              if cancelled:
              you get futurepayID, FuturePayStatusChange only and you use futurepayID to updat the data.

                100% correct

                if approved:
                you get all the fields and you use cartID to update the data.

                if cancelled:
                you get futurepayID, FuturePayStatusChange only and you use futurepayID to updat the data.

                I'll just phrase it slightly differently in case it makes it clearer:

                if A PAYMENT IS MADE (the payment can be approved, or fail):
                you get all the fields and you use cartID to update the data.

                if THE PAYMENT SUBSCRIPTION IS cancelled:
                you get futurepayID, FuturePayStatusChange only and you use futurepayID to updat the data.

                as of course in this case, no transaction has taken place

                  So why not just have 2 separate queries?

                  <?php
                  
                  if($cartID)
                  {
                    // Must be Approved or Failed payment
                     $query_rsusers1 = "UPDATE users SET transStatus = '".$transtatusField."',
                  transID = '".$transIDField."',
                  cartID = '".$cartID."',
                  amount = '".$amountField."',
                  futurepayID = '".$futurePayIDField."',
                  FuturePayStatusChange = '".$futurePaystatusChange."',
                  ut1 = '".$PaymentIDField."'
                    WHERE Uid = '".$cartID."'"; 
                  }
                  else
                  {
                    // Must be a cancellation:
                    $query_rsusers1 = "UPDATE users SET FuturepayStatusChange = '".$futurepaystatusChange."' WHERE futurepayID = '".$futurePayIDField."'";
                  }

                  That seems to be a suitable solution, wouldn't you say?

                    thanks, that's perfect.

                    It's working and I'm learning a lot.

                    Cheers,

                    V.

                      Glad to hear you got it working!!

                        Write a Reply...