Author Topic: Password SQL and MariaDB  (Read 234 times)

Offline nigihayami

  • Newbie
  • *
  • Posts: 1
Password SQL and MariaDB
« on: September 26, 2016, 05:10:48 AM »
Code: [Select]
CREATE FUNCTION update_password (oldpass text, cryptpass text, user text) RETURNS text
        MODIFIES SQL DATA
    BEGIN
        DECLARE currentsalt varchar(20);
        DECLARE error text;
        SET error = 'incorrect current password';
        SELECT substring_index(substr(user.password,4),_latin1'$',1) INTO currentsalt FROM users WHERE username=user;
        SELECT '' INTO error FROM users WHERE username=user AND password=ENCRYPT(oldpass,currentsalt);
        UPDATE users SET password=cryptpass WHERE username=user AND password=ENCRYPT(oldpass,currentsalt);
        RETURN error;
    END
Didn't work, Mariadb said :
Code: [Select]
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 4 What should i do? I'm using 10.0.25-MariaDB