Function AddUser

Posted on 2014-12-12
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:-
CREATE FUNCTION AddUser(username VARCHAR(255, password VARCHAR(255))
	INSERT INTO `users` (`username`, `password`) VALUES (username, AES_ENCRYPT(password,'cryptstring')); 

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?
Question by:tonelm54
  • 2
LVL 51

Expert Comment

ID: 40496591
try comment out some lines

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

find where the problem is first...
LVL 51

Accepted Solution

HainKurt 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))
	INSERT INTO `users` (`username`, `password`) VALUES (username, AES_ENCRYPT(password,'cryptstring')); 

Open in new window

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

check MySQL Reference

Author Closing Comment

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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sql query help 2 46
sql query help 4 45
MS Access how to nest many values to one value when exporting query to XML format 8 46
RDBMS and No sql database 4 46
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Sending a Secure fax is easy with eFax Corporate ( First, just open a new email message. In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

867 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now