Announcement

Collapse
No announcement yet.

help with event - update db

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • help with event - update db

    hey folks.

    not sure if this is my lousy coding or what.. but I could do with a little hand in solving this.
    Am trying to update the mbr table if date is today or past, the below code seems to work to an extent just that it updates regardless if true or false....
    Any help would be appreciated as other forums have now reached a loss, have tried a few different combinations and have the same result each time... GRRRR

    Event is onScriptInit - Form
    Code:
    $exp_date = "{mbrDateValid}";
    		$todays_date = date("Y-m-d");
    		
    		$today = strtotime($todays_date);
    		$expiration_date = strtotime($exp_date);
    		
    		if ($expiration_date > $today) 
    		{
    
    			// SQL statement parameters
    			$update_table  = 'mbr';      // Table name
    			$update_where  = "mbrID = '{mbrID}'"; // Where clause
    			$update_fields = array(   // Field list, add as many as needed
    				 "mbrPaid = '0'",
    				 "mbrDateValid = '0000-00-00'",
    			 );
    			
    			// Update record
    			$update_sql = 'UPDATE ' . $update_table
    				. ' SET '   . implode(', ', $update_fields)
    				. ' WHERE ' . $update_where;
    			sc_exec_sql($update_sql);
    		} 
    		else 
    		{
    			 
    		}
    have the if statement working fine within a grid changing the field color, which works great, so am not sure why the same statement is failing within a form....
    Last edited by jamieO; 06-14-2013, 11:32 AM.

  • #2
    $exp_date = {mbrDateValid};

    perhaps?
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      Originally posted by aducom View Post
      $exp_date = {mbrDateValid};

      perhaps?
      lol like I said lousy coding thx

      Comment


      • #4
        still trying to get used to the new way of doing thing am getting there slowly

        Comment


        • #5
          Turn on debug mode (if you haven't already). That should help you a lot.

          regards,
          Bernhard Bernsmann

          Comment


          • #6
            Originally posted by bartho View Post
            Turn on debug mode (if you haven't already). That should help you a lot.

            regards,
            Bernhard Bernsmann
            cool will do thx

            Comment


            • #7
              ok where do I turn on debug mode? cant seem to find the option in settings or my scriptcase...

              Comment


              • #8
                You can set it in every form/grid under Apllication-Settings

                Other question: where did you get the {mbrDateValid} from ?

                Comment


                • #9
                  Originally posted by Gerd Dietrich View Post
                  You can set it in every form/grid under Apllication-Settings

                  Other question: where did you get the {mbrDateValid} from ?
                  thx!

                  the {mbrDateValid} is one of my form/db fields, so local variable within the form.

                  Comment

                  Working...
                  X