Adding New Collumns

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

Adding New Collumns

Post by Straterra »

I get this error :

Warning: sqlite_query(): near "ALTER": syntax error in c:\ftp\users\straterra\eck\cgi-bin\newcollumn.php on line 7


When I use this code :

Code: Select all

<?php
$dbname = 'eckbios';
if ($db = sqlite_open($dbname, 0666, $sqliteerror)){
sqlite_query($db, "ALTER TABLE clanprofile
ADD bgcolor VARCHAR (30),
ADD textcolor VARCHAR (30)
");
} else {
  die ($sqliteerror);
}
?>
Can anyone tell me what I did wrong?
Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

Post by Straterra »

I found out why. SQLite doesn't support the ALTER command. I have to put the table data into a temporary table and delete the old table, then create a new table with the new collumns and then insert the data from the temporary table into that...Anyone know how to do that?
Post Reply