I am using SQLite for an iPhone application and I am using this query:
NSString *query = [[NSString alloc] initWithFormat:@"INSERT INTO Courses (name, credits, web, tName, tSurname, tMail, tOffice) VALUES (\'%@\', \'%@\', \'%@\', \'%@\', \'%@\', \'%@\', \'%@\');", self.name, self.credits, self.web, self.tName, self.tSurname, self.tMail, self.tOffice];
This is a simple INSERT, but I am from Spain and I have problems with tildes. If I do something like:
INSERT INTO Courses (name, credits, web, tName, tSurname, tMail, tOffice) VALUES ('test', 'test', 'test', 'test', 'test', 'test', 'test');", self.name, self.credits, self.web, self.tName, self.tSurname, self.tMail, self.tOffice];
Everything works perfectly.
The problem arises when I insert with two or more words with special characters, such as ¿, ¡, `, ', ... And I don’t know how to fix it: S If only the request contains a special character in which there is no problem .
For instance:
This query works (because only á exists):
INSERT INTO Courses (name, credits, web, tName, tSurname, tMail, tOffice) VALUES ('Matemáticas', '1', '', 'Name', 'Surname', ' a@a.com ', '');", self.name, self.credits, self.web, self.tName, self.tSurname, self.tMail, self.tOffice];
This query returns me the error "Error: next to" ": syntax error" (because there are "-" and "à"):
INSERT INTO Courses (name, credits, web, tName, tSurname, tMail, tOffice) VALUES ('Gestió', '1', '', 'à', 'Surname', ' a@a.com ', '');", self.name, self.credits, self.web, self.tName, self.tSurname, self.tMail, self.tOffice];
I tried to put the words between "and between," and I get the same thing.
Any idea?