Jump to content

Light SQLite trouble..


jdoe

Recommended Posts

Having just a little trouble with SQLite. I'm running 5.1.3 CGI, with the sqlite, pdo, and (unnecessarily) the pdo_sqlite extensions enabled, on Apache 2.0.55 under XP Pro.

I'm trying to, at the head of my script, have SQLite create a table as long as one of the same name doesn't already exist. I read the correct syntax is "CREATE TABLE IF NOT EXISTS," but when I try this, as in this example code:

[code]<?php

$db = new SQLiteDatabase("test.db");

$db->query("CREATE TABLE IF NOT EXISTS foo(id INTEGER PRIMARY KEY, name CHAR(255)");

?>[/code]

I get the following error:

[code]Warning: SQLiteDatabase::query() [function.SQLiteDatabase-query]: near "NOT": syntax error in test.php on line 5[/code]

What's causing this; what am I doing wrong?

I know it's gotta be something simple, but it's driving me nuts! After a few tests, I'm excited to work with this terrific database system, absolutely perfect for my application, but am stuck due to this!

Any help's much obliged!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.