Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7860857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:28:08+00:00 2026-06-02T22:28:08+00:00

I’m trying to link sqlite3, create table and insert data but got this error:

  • 0

I’m trying to link sqlite3, create table and insert data but got this error:

'NSInternalInconsistencyException', reason: 'Error creating table: near "4": syntax error' *** First throw call stack:(0x15ad022 0x173ecd6 0x1555a48 0xa852cb 0x2bea 0x273a 0x1b5a1e 0x114401 0x114670 0x114836 0x11b72a 0x2415 0xec386 0xed274 0xfc183 0xfcc38 0xf0634 0x1497ef5 0x1581195 0x14e5ff2 0x14e48da 0x14e3d84 0x14e3c9b 0xecc65 0xee626 0x20d2 0x2045 0x1)

the code:

- (void) openDBcreateTable {
if (sqlite3_open([[self filePath]UTF8String], &db) != SQLITE_OK) {
    sqlite3_close(db);
    NSAssert(0, @"Failed to open database");
}
//create table named QUESTIONBANK
NSString *createSQL = @"CREATE TABLE IF NOT EXISTS QUESTIONBANK(ROW INTEGER PRIMARY KEY, QUESTION TEXT, ANSWER TEXT, CHOICE1 TEXT, CHOICE2 TEXT, CHOICE3 TEXT, CHOICE 4 TEXT, USERANSWER TEXT);";

char *errorMsg1;

if (sqlite3_exec(db, [createSQL UTF8String], NULL, NULL, &errorMsg1) != SQLITE_OK) {
    sqlite3_close(db);
    NSAssert(0,@"Error creating table: %s", errorMsg1);
}

for (int k = 1; k < 11; k++) {
    NSMutableArray *questionBlocks = [self pullDataFromSomeWhere];
    NSString *question = [NSString stringWithFormat:[questionBlocks objectAtIndex:0]];
    NSString *answer = [NSString stringWithFormat:[questionBlocks objectAtIndex:1]];
    NSString *choice1 = [NSString stringWithFormat:[questionBlocks objectAtIndex:2]];
    NSString *choice2 = [NSString stringWithFormat:[questionBlocks objectAtIndex:3]];
    NSString *choice3 = [NSString stringWithFormat:[questionBlocks objectAtIndex:4]];
    NSString *choice4 = [NSString stringWithFormat:[questionBlocks objectAtIndex:5]];

    char *update = "INSERT OR REPLACE INTO QUESTIONBANK(ROW,QUESTION,ANSWER,CHOICE1,CHOICE2,CHOICE3,CHOICE4)VALUES(?,?,?,?,?,?,?);";


    sqlite3_stmt *stmt;

    if (sqlite3_prepare_v2(db, update, -1, &stmt, nil) == SQLITE_OK) {
        sqlite3_bind_int(stmt, 1, k);
        sqlite3_bind_text(stmt, 2, [question UTF8String], -1, NULL);
        sqlite3_bind_text(stmt, 3, [answer UTF8String], -1, NULL);
        sqlite3_bind_text(stmt, 4, [choice1 UTF8String], -1, NULL);
        sqlite3_bind_text(stmt, 5, [choice2 UTF8String], -1, NULL);
        sqlite3_bind_text(stmt, 6, [choice3 UTF8String], -1, NULL);
        sqlite3_bind_text(stmt, 7, [choice4 UTF8String], -1, NULL);

    }
    if (sqlite3_step(stmt) != SQLITE_DONE) {
        NSAssert(0,@"Error updating table");
    }
    sqlite3_finalize(stmt);
}
sqlite3_close(db);}

I’m also very confident that there are other errors since i’m still new to sqlite 3. While we’re at this, is there any ‘VARCHAR’, ‘BLOB’ etc (like MySQL) that i can use in sqlite3?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T22:28:10+00:00Added an answer on June 2, 2026 at 10:28 pm

    Remove the spurious ‘4’ in the create table statement:

    ... CHOICE 4 TEXT ...

    should be:

    ... CHOICE TEXT ...

    The error message is fairly self-explanatory.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to construct a data frame in an Rcpp function, but when I
I'm trying to create an if statement in PHP that prevents a single post
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.