PDA

View Full Version : Update database problem, syntax error.


Mhtml
10-11-2002, 08:23 AM
I've made a mailing list script and I have added a admin option to change the look of the gui, eg colors border styles link colors etc.

I got my pages to read the database and adjust the stylesheet accordingly but I can't seem to get the update string to work.

The error I am getting is this:
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression '072f95'.

The line in question is line 19, which is the execute for the sql update string.

SqlUpdate = "UPDATE GUI SET imageUrl ="& imageUrl&", MenuBgColor ="& MenuBgColor &", MenuLinkColor ="& MenuLinkColor &", MenuBorderStyle =" & MenuBorderStyle &", MenuBorderWidth =" & MenuBorderWidth &", MenuBorderColor =" & MenuBorderColor & ", MainTextColor =" & MainTextColor &", MainLinkColor =" & MainLinkColor &", MainBgColor =" & MainBgColor &", AlternateColorOne =" & AlternateColorOne & ", AlternateColorTwo =" & AlternateColorTwo & ") WHERE ID=1"



All the variables are defined earlier in the document and are correct. But it is getting stuck at the mainlinkcolor variable with that weird syntax error, the info being sent for mainlinkcolor when this occured was 072f95.

glenngv
10-11-2002, 09:35 AM
to debug easily, response.write the sql statement.

response.write SqlUpdate


and take note that you should have single quotes between values of a varchar field

"UPDATE GUI SET imageUrl ='"& imageUrl&"', MenuBgColor ='"& MenuBgColor &"', ......"

raf
10-11-2002, 09:43 AM
where does the ) before the condition comes from ?

when you get this 'missing operator' error, it's usually because of a redundant quote (in my limited experience)

i always build my sql statements in a different (and i believe smarter) way, which avoids syntax errors + is clearlier structured. I don't fill the values in, in the actual string, but fill them in by replacing dummy's. Like this



dim sql1
sql1="select BTAuser,ICQ,email from gebruikers where BTAuser='auser' or ICQ=anICQ or email='anemail'"
sql1=replace(sql1,"auser",replace(request.form(user),"'","''"))
sql1=replace(sql1,"anICQ",session("ICQ"))
sql1=replace(sql1,"anemail",request.querystring("email"))



Maybe try it this way. Its easier for troubleshooting (i think)

Mhtml
10-11-2002, 10:08 AM
The ) was from whe I was going to use INSERT but realised that I needed to update.

Thanks for the tip by the way, it works perfectly now.