Solved

Function AddUser

Posted on 2014-12-12
3
124 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
  • 2
3 Comments
 
LVL 51

Expert Comment

by:HainKurt
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 51

Accepted Solution

by:
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))
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

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 (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. 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