Messages - Davidtheo [ switch to compact view ]

Pages: [1] 2 3 4 5 6 ... 24next
1
Developer's Corner / Re: SQlite + Php 5.2.9 + Apache2.2
« on: July 21, 2009, 01:25 AM »
please help

2
Developer's Corner / Re: SQlite + Php 5.2.9 + Apache2.2
« on: July 21, 2009, 01:24 AM »

If it doesn't exist yet, perhaps a CREATE DATABASE DEVDB where DEVDB is the name of the database...


With this line if the DB file does not exist it will create and open it. If it does exist it will open it.

sqlite_open('jx3.db', 0666, $sqliteerror)

3
Developer's Corner / Re: SQlite + Php 5.2.9 + Apache2.2
« on: July 21, 2009, 01:21 AM »
Everywhere I have looked says it is supported and it works without the "IF NOT EXISTS".

There is the rest of the code - some columns I am using the try catch in replace of the "IF NOT EXISTS"  :-[ and it works without the "IF NOT EXISTS"

$mysql = "CREATE TABLE startup (row_id INTEGER PRIMARY KEY, ";
$mysql .= "games TEXT NOT NULL, ";
$mysql .= "user_id TEXT NOT NULL, ";
.
.
.
.
$mysql .= "age TEXT ";
.
.
$mysql .= "); ";

if ($db = sqlite_open('jx3.db', 0666, $sqliteerror)) {
//catch if database is already there
try{
sqlite_query($db,$mysql);
} catch(Exception $e){

}

$mysql = "INSERT INTO startup (games,user_id,age";
.
.
.
.
$mysql .= ") VALUES (\"";
$mysql .= $var_games . "\",\"" .$var_id . "\",\"";
.
.
.
.
$mysql .= $var_age . "\")";

sqlite_query($db, $mysql) or die("Error in query: ".sqlite_error_string(sqlite_last_error($db)));

But when I use the "IF NOT EXISTS" it gives me a error  :( :( I do not understand why??

$mysql = "CREATE TABLE IF NOT EXISTS startup (row_id INTEGER PRIMARY KEY, ";
$mysql .= "games TEXT NOT NULL, ";
$mysql .= "user_id TEXT NOT NULL, ";
.
.
.
.
$mysql .= "age TEXT ";
.
.
$mysql .= "); ";

if ($db = sqlite_open('jx3.db', 0666, $sqliteerror)) {

sqlite_query($db,$mysql);

$mysql = "INSERT INTO startup (games,user_id,age";
.
.
.
.
$mysql .= ") VALUES (\"";
$mysql .= $var_games . "\",\"" .$var_id . "\",\"";
.
.
.
.
$mysql .= $var_age . "\")";

sqlite_query($db, $mysql) or die("Error in query: ".sqlite_error_string(sqlite_last_error($db)));


4
Developer's Corner / SQlite + Php 5.2.9 + Apache2.2
« on: July 19, 2009, 09:20 PM »
Can someone please help me with sqlite.

I am using SQlite + Php 5.2.9 + Apache2.2.

I can create a table using "CREATE TABLE startup (row_id INTEGER PRIMARY KEY"

But when I try to use "CREATE TABLE startup IF NOT EXISTS (row_id INTEGER PRIMARY KEY" or "CREATE TABLE IF NOT EXISTS startup (row_id INTEGER PRIMARY KEY" I am getting this error.

"Error in query: SQL logic error or missing database"

Does anyone know if the "IF NOT EXISTS" statement can be used with SQlite, Php 5.2.9 + Apache2.2. or is there an other way of checking if a table does exists before trying to create it.

5
Developer's Corner / Re: PHP Database help.
« on: May 24, 2009, 08:22 PM »
OK How would this be done in PHP???? IF I can do this in PHP I do not need to change my server account to MS.

Pages: [1] 2 3 4 5 6 ... 24next
Go to full version