'm using asp with a MySql page -- workingon someone elses work. I have a script that updates the datbase just fine, however, when I add a field to the form, the insert page no longer works. Can someone tell me why adding one field throughs the entire script off. The field has been added to my database.
This sql statement is created with an array and I usually create the sql statements by specifying fields. I am pasting the update script for anyone to review. Thanks
-----------------------------------
Public Function FixQuotes(ByVal strValue)
FixQuotes = Replace(Replace(Replace(trim(strValue), "'", "''"),chr(13)," "),chr(10),"")
End Function
Function sqlInsert(array,table_name)
strSql="select settingValue from settings where setting='pEncryptionPassword'"
set rs=conn.execute(strSql)
Pwd=rs(0)
set rs = nothing
For Each field in array
If len(array(field)) > 0 Then
columns = columns & field &","
If field = "card_number" Then
values = values & "encode('"& array(field) &"','"&Pwd&"'),"
Else
values = values & "'" & FixQuotes(array(field)) & "',"
End If
End If
Next
columns = StrReverse(Replace(StrReverse(columns),",","",1,1))
values = StrReverse(Replace(StrReverse(values),",","",1,1))
sqlInsert = "INSERT INTO " & table_name & " (time_stamp, " & columns & ")" & " VALUES ('"& MySqlDate(now) &"'," & values & ")"
End Function
conn.execute sqlInsert(request.form,"orders")
This sql statement is created with an array and I usually create the sql statements by specifying fields. I am pasting the update script for anyone to review. Thanks
-----------------------------------
Public Function FixQuotes(ByVal strValue)
FixQuotes = Replace(Replace(Replace(trim(strValue), "'", "''"),chr(13)," "),chr(10),"")
End Function
Function sqlInsert(array,table_name)
strSql="select settingValue from settings where setting='pEncryptionPassword'"
set rs=conn.execute(strSql)
Pwd=rs(0)
set rs = nothing
For Each field in array
If len(array(field)) > 0 Then
columns = columns & field &","
If field = "card_number" Then
values = values & "encode('"& array(field) &"','"&Pwd&"'),"
Else
values = values & "'" & FixQuotes(array(field)) & "',"
End If
End If
Next
columns = StrReverse(Replace(StrReverse(columns),",","",1,1))
values = StrReverse(Replace(StrReverse(values),",","",1,1))
sqlInsert = "INSERT INTO " & table_name & " (time_stamp, " & columns & ")" & " VALUES ('"& MySqlDate(now) &"'," & values & ")"
End Function
conn.execute sqlInsert(request.form,"orders")