0

Good Morning,

This may be a simple yes or no, or hopefully if it is a no, someone can tell me how to work around it.

I have a table that includes 4 columns named the same with incremented numbers in the names

step1 / step2 / step3 / step4

I have a function in an obscure/remote place that I can't see the results of while it is being run, but don't seem to be getting the update that I expect from it.

I'm wondering if the structure of the update query is causing the problem or if I need to look somewhere else.

I'm trying to set the 'name' of the field to be updated through using a variable assigned in a switch case scenario.

        // #################################################
        //  UPDATE earned date for step1 - step4 in rewards prime

        switch($prime_reward_step){
          case 1:
            $step_value = 'step1';
            break;
          case 2:
            $step_value = 'step2';
            break;
          case 3:
            $step_value = 'step3';
            break;
          default:
            $step_value = 'step4';
            break;
        }

        $sql_u = "
          UPDATE rewards_prime
          SET ".$step_value."='".$created."'
          WHERE pid='".$prime_reward_pid."'
        ";
        mysql_query($sql_u);
        // #################################################

everything up before this point works, and the values assigned and updated, but not this one.

I'd like to know if using the $step_value as the column name is an acceptable format, and if not what would be a reasonable way to work around it.

thanks
Douglas

3
Contributors
4
Replies
17
Views
2 Years
Discussion Span
Last Post by showman13
0

Thank you both for responding...

iamthwee - the $created variable is passed into the function and is used in other queries that are functioning correctly, so it wouldn't be the issue, but it is set like this

$created = date("Y-m-d H:i:s", time()) ;

pritaeas - The problem with this is that the function is actually in a behind the scenes script that is called by a payment processor as the notification script on a successful payment, so even if I added the die to the query, I wouldn't see the results.

0

OK, I figured it out...

It wasn't that the query wasn't working, it was that the $prime_reward_step variable didn't have any value so it didn't know what to do.

Sorry to have bothered you with this...

Douglas

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.