I get a very unhelpful SQL error from Railo when trying to do an insert. I think it has something to do with the :param values I am passing to it; as when I take these out and replace them with a simple string, it works.
Here's my code (which sits inside a CFC):
local.registerUserQuery = new query();
local.registerUserQuery.setDatasource("popwave");
local.registerUserQuery.setSQL("
INSERT INTO users (
userUUID,
userName,
userPassword,
userEmail,
userToken,
userCreated,
userBiography,
userCommentPoints,
userLinkPoints,
userImageID,
userRemoved,
userCategoriesOwner,
userCategoriesSubscribed
)
VALUES (
'#createUUID()#' ,
:userName ,
:userPassword ,
:userEmail ,
'#local.token#' ,
#createODBCDate(now())# ,
'' ,
0,
0,
0,
0,
0,
0
)
");
local.registerUserQuery.setName("registerUser");
local.registerUserQuery.addParam( name="userName", value="#arguments.userName#", cfsqltype="cf_sql_varchar" );
local.registerUserQuery.addParam( name="userPassword", value="#arguments.userPassword#", cfsqltype="cf_sql_varchar" );
local.registerUserQuery.addParam( name="userEmail", value="#arguments.userEmail#", cfsqltype="cf_sql_varchar" );
local.registerUserQuery.execute();
I cannot understand for the life of me why this is throwing an error! I need to be able to use :param's.
Here's the Railo error:
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 '' at line 49
Examining that line number does not seem to point to anything related. This query is on something like line 200! And, as mentioned earlier...the SQL seems to work when I replace these :param values.
Is there actually something I am doing wrong here? Pulling my hair out!
Thanks, Michael.
EDIT:
Forgot to mention, the Railo version is:
Railo 3.3.1.000 Error (database)