Solved

Function AddUser

Posted on 2014-12-12
3
135 Views
Last Modified: 2015-01-03
Long time since Ive done any functions in MySQL and Im a bit stuck.

From memory Ive got the following:-
DROP FUNCTION IF EXISTS AddUser
DELIMITER $$
CREATE FUNCTION AddUser(username VARCHAR(255, password VARCHAR(255))
BEGIN
	INSERT INTO `users` (`username`, `password`) VALUES (username, AES_ENCRYPT(password,'cryptstring')); 
END;
$$
DELIMITER ;

Open in new window


I thought the issue was with the parameters, however the error is:-
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO `users` (`username`, `password`) VALUES (username, AES_ENCRYPT(passw' at line 3

Any ideas, what Im doing wrong?
0
Comment
Question by:tonelm54
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 53

Expert Comment

by:Huseyin KAHRAMAN
ID: 40496591
try comment out some lines

delete/comment out line 2,7,8 and try again...

find where the problem is first...
0
 
LVL 53

Accepted Solution

by:
Huseyin KAHRAMAN earned 500 total points
ID: 40496601
the other thing is this does not look like a function but procedure

CREATE PROCEDURE AddUser(username VARCHAR(255, password VARCHAR(255))
BEGIN
	INSERT INTO `users` (`username`, `password`) VALUES (username, AES_ENCRYPT(password,'cryptstring')); 
END;

Open in new window


if it is really a function, where is the return clause?

check MySQL Reference
0
 

Author Closing Comment

by:tonelm54
ID: 40529480
Thank you, forgot about procedures (told you it was a while...)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question