title: how to declare variable phpmyadmin mysql triggers properly?
body: <p>I have a database where whenever residential address update in user table I want it to store in history table of user. For that I'm trying to write triggers but failing miserably in phpmyadmin. Also it's not giving me proper reason why so I can correct it. This is what I have done so far.</p>
  
  <pre><code>DROP TRIGGER IF EXISTS `record_history`;
  CREATE TRIGGER `record_history` AFTER UPDATE ON `s_user` 
  FOR EACH ROW
  BEGIN
      DECLARE date_current datetime;
      DECLARE residential_address varchar(1000);
      SET @date_current = NOW();
      SET @residential_address = NEW.residential_address;
      IF (@residential_address &lt;&gt; OLD.residential_address AND @residential_address != "" AND @residential_address IS NOT NULL) THEN
          INSERT INTO history_residential_address (`s_u_id`, `residential_address`, `status`, `date_added`, `date_updated`) VALUES 
          (OLD.s_u_id, @residential_address, 1, @date_current, @date_current);
      END IF;
  END;
  delimiter ;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/e7yzv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e7yzv.png" alt="Mysql Trigger Failed"></a></p>