repeat with
Jim Ault
JimAultWins at yahoo.com
Fri Jan 13 18:36:55 EST 2006
On 1/13/06 12:45 PM, "liamlambert" <liamlambert at mac.com> wrote:
<full text below>
Try this version with 3 things...
a field name spelling check
and a bug fix after the repeat loop
also a method of putting the var contents in the msg box so you can review
-----------------------------------------
on fSave
global gConID
--intentionally misspelled the field name
put "name1,phone,child,adultSSS" into tFieldNames
repeat for each item tField in tFieldNames
if there is not a field tField then
answer "oooops, misspelling of " & tField
exit to top
end if
put "'" & cleanSQL (field tField) & "'" & "," after tRowData
end repeat
delete last char of tRowData -- this nukes a trailing comma
--this is one of the dangers of a FOR EACH concatenation loop
--either a starting or ending character to delete
-- now, so you can see the result after exiting the loop
put "tRowData contains" & cr & tRowData into msg
end fSave
function cleanSQL incmg
return incmg
end cleanSQL
-------------------------------------------------
Jim Ault
Las Vegas
On 1/13/06 12:45 PM, "liamlambert" <liamlambert at mac.com> wrote:
> I have not set the itemDel
>
> on fSave
> global gConID
>
> if fld "total" is empty then
> answer error "THERE IS NO TOTAL" as sheet exit to top
> end if
>
> put
> "name1,phone,child,adult,total,credit,paymenttype,address,address1,addre
> ss2,email,seatNo,ticket,showID" into tFieldNames
> repeat for each item tField in tFieldNames
> put "'" & cleanSQL (field tField) & "'" & "," after tRowData
> end repeat
>
>
> put "INSERT INTO showDb
> (userID,name,phone,child,adult,total,credit,paymenttype,address,address1
> ,address2,email,seatNo,ticket,showID)" & \
> " VALUES(null," & tRowData & ")" into tSQL
>
> put revdb_execute(gConID,tSQL) into tTmp
>
>
> put empty into fld "name1"
> put empty into fld "phone"
> put empty into fld "child"
> put empty into fld "adult"
> put empty into fld "total"
> put empty into fld "credit"
> put empty into fld "address"
> put empty into fld "address1"
> put empty into fld "address2"
> put empty into fld "email"
>
> put empty into fld "childprice"
> put empty into fld "adultprice"
>
>
> ----->refresh
> get fld "showid"
> put it into tshowid
> put "SELECT
> userid,name,phone,child,adult,total,credit,paymenttype,seatNo,ticket,sho
> wid FROM showDb WHERE showid = '" & tshowid & "'" into tSQL
> --> EXECUTE SQL
> put revdb_querylist(,,gConID,tSQL) into tList
> put tList into fld "list"
> end fsave
>
>
>
> function cleanSQL pSQL
> --> THIS ESCAPES THE QUOTE PROBLEM IN SQL
> replace "'" with "''" in pSQL
> replace quote with quote & quote in pSQL
> --> THIS ESCAPES THE tab AND cr DELIMITERS
> --> IF YOU PLAN ON HAVING USERS ENTER cr AND tab THEN YOU ALSO
> NEED TO
> --> replace "*CR*" with cr IN THE RETURNED DATA!
> replace cr with "*CR*" in pSQL
> replace tab with "*TAB*" in pSQL
> return pSQL
> end cleanSQL
>
> Liam Lambert
> liamlambert at mac.com
> IRELAND
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list