开发者

SQLITE and iPhone Input Sanitisation

We are making our very first iPhone game, and if the user gets a high score then we need to let them enter their name to st开发者_StackOverflowore it in the high-scores database inside the app.

What I was wondering is how do we go about sanitising the input on the iPhone. Obviously we don't want them dropping tables when inputting their name!

Can anybody please offer any advice or a push in the right direction?

Thanks, Dwaine


At the very least, you should be using parameterized queries.

For example:

sqlite3_reset(insertStatement);

sqlite3_bind_text(insertStatement, 1, [userInput UTF8String], -1, SQLITE_TRANSIENT);

if(SQLITE_DONE != sqlite3_step(insertStatement))
{
    //handle error

//etc...

You could also use Core Data and rely on it to handle the implementation details. That'd be my recommendation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜