The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Mod Create new Table..
Hey im working on a plugin and i want this plugin to create a new table in the database and i don´t know how i should get it work i only get error so can somebody give the code that creates a new table that i can put in?
|
#2
|
|||
|
|||
Just Google "MySQL Create Table" you will get loads of tutorials/guides and the official documentation.
|
#3
|
||||
|
||||
$db->query_write("CREATE TABLE test (testid integer NOT NULL PRIMARY KEY auto_increment, testname text)");
|
#4
|
|||
|
|||
Quote:
Code:
Database error in vBulletin 3.7.0 Beta 3: Invalid SQL: CREATE TABLE vb_news (id integer NOT NULL PRIMARY KEY auto_increment, title varchar, date date, time time, poster varchar, text text); MySQL Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' date date, time time, poster varchar, text text)' at line 1 Error Number : 1064 Date : Wednesday, January 16th 2008 @ 09:17:28 PM Script : http://test.fanrage.org/testvb/admin/plugin.php?do=productimport Referrer : http://test.fanrage.org/testvb/admin/plugin.php?do=productadd IP Address : 85.224.63.34 Username : John Classname : vB_Database MySQL Version : 5.0.18-nt-log |
#5
|
|||
|
|||
date and time are MySQL keywords I think and also text. Make sure the column names aren't the same as the column types. Also enclose the column names in single quotes.
|
#6
|
|||
|
|||
i tried this now
Code:
$db->query_write("CREATE TABLE " . TABLE_PREFIX . "news (id integer NOT NULL PRIMARY KEY auto_increment, title varchar, date varchar, time varchar, poster varchar, newst text)"); Code:
Database error in vBulletin 3.7.0 Beta 3: Invalid SQL: CREATE TABLE vb_news (id integer NOT NULL PRIMARY KEY auto_increment, title varchar, date varchar, time varchar, poster varchar, newst text); MySQL Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' date varchar, time varchar, poster varchar, newst text)' at line 1 Error Number : 1064 Date : Wednesday, January 16th 2008 @ 09:49:56 PM Script : http://test.fanrage.org/testvb/admin/plugin.php?do=productimport Referrer : http://test.fanrage.org/testvb/admin/plugin.php?do=productadd IP Address : 85.224.63.34 Username : John Classname : vB_Database MySQL Version : 5.0.18-nt-log |
#7
|
||||
|
||||
You can't name a field "date" or "time", you need to rename those, ex:
Code:
$db->query_write("CREATE TABLE " . TABLE_PREFIX . "news (id integer NOT NULL PRIMARY KEY auto_increment, title varchar, newsdate varchar, newstime varchar, poster varchar, newst text)"); |
#8
|
|||
|
|||
Quote:
but i still get error when i use the one you wrote here. Code:
Database error in vBulletin 3.7.0 Beta 3: Invalid SQL: CREATE TABLE vb_news (id integer NOT NULL PRIMARY KEY auto_increment, title varchar, newsdate varchar, newstime varchar, poster varchar, newst text); MySQL Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' newsdate varchar, newstime varchar, poster varchar, newst text)' at line 1 Error Number : 1064 Date : Wednesday, January 16th 2008 @ 10:04:39 PM Script : http://test.fanrage.org/testvb/admin/plugin.php?do=productimport Referrer : http://test.fanrage.org/testvb/admin/plugin.php?do=productadd IP Address : 85.224.63.34 Username : John Classname : vB_Database MySQL Version : 5.0.18-nt-log |
#9
|
|||
|
|||
Varchar type requires a length. Not optional.
Code:
CREATE TABLE vb_news (id integer NOT NULL PRIMARY KEY auto_increment, title varchar(128), newsdate varchar(10), newstime varchar(10), poster varchar(32), newst text); |
#10
|
|||
|
|||
Quote:
--------------- Added [DATE]1200518572[/DATE] at [TIME]1200518572[/TIME] --------------- okey got another question related to this. i want the date to be saved like MM/DD/YYYY but i want it to be shown as the option says in acp. like this: 1st January 2008 |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|