SQLite insert data from variables: error unrecognized token

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
chris0879
Posts: 6
Joined: Thu May 28, 2015 2:59 pm

SQLite insert data from variables: error unrecognized token

Post by chris0879 » Tue Jun 02, 2015 12:20 pm

this bis my code:

Code: Select all


on mouseUp
   
   databaseConnect
    
    local tFname
put "myname" into Nome
   put "myemail" into Mail
   
    put getDatabaseID() into tDatabaseID
    
    
    put "INSERT into contact_details    (nome, email)         VALUES (' " & Nome& " '," & Mail& "');" into tSQL
       
    

    
    revExecuteSQL tDatabaseID, tSQL
   
   put the result into tRes
   if tRes is not a number then
      answer error "There was a problem saving this record: " & tRes as sheet
   end if
   
   
   
   
end mouseUp




error display: unrecognized token.

where is the error?
Thanks!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10394
Joined: Wed May 06, 2009 2:28 pm

Re: SQLite insert data from variables: error unrecognized to

Post by dunbarx » Tue Jun 02, 2015 1:14 pm

Hi.

Which line threw the error?

Craig Newman

chris0879
Posts: 6
Joined: Thu May 28, 2015 2:59 pm

Re: SQLite insert data from variables: error unrecognized to

Post by chris0879 » Tue Jun 02, 2015 1:28 pm

I can not see where it blocks the code!
This is a screenshot of the error!
thanks!
Attachments
error.jpg

chris0879
Posts: 6
Joined: Thu May 28, 2015 2:59 pm

Re: SQLite insert data from variables: error unrecognized to

Post by chris0879 » Tue Jun 02, 2015 1:48 pm

I solved:
after comma
VALUES (' " & Nome& " ',
omit
'
thanks anyway!

Klaus
Posts: 14267
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: SQLite insert data from variables: error unrecognized to

Post by Klaus » Tue Jun 02, 2015 1:50 pm

Hi Chris,

in cases like this always check the resulting SQL, here is what your script will produce:
...
INSERT into contact_details    (nome, email)         VALUES (' myname ',myemail');
...
Lots of SPACES***, and even missing single quotes...
No wonder this will create an error.
8)
***Will maybe not harm the funcitonality, but makes it very hard to read!


Best

Klaus

Post Reply