PDA

View Full Version : Help with add field vb/php syntax


Tekton
09-18-2004, 05:54 PM
$DB_site->query(" ALTER TABLE " . TABLE_PREFIX . "table
ADD test int(10) unsigned DEFAULT '0' NOT NULL
");


I looked at the SQL examples from vb.com's docs (http://www.vbulletin.com/docs/html/codestandards) , but none of them seem to work either.

Zachery
09-18-2004, 08:16 PM
$DB_site->query(" ALTER TABLE " . TABLE_PREFIX . "table
ADD test int(10) unsigned DEFAULT '0' NOT NULL
");


I looked at the SQL examples from vb.com's docs (http://www.vbulletin.com/docs/html/codestandards) , but none of them seem to work either.
Are you making a installer or somthing just trying to expand your own table?

Tekton
09-18-2004, 08:19 PM
Expand a table.

nexialys
09-18-2004, 08:34 PM
but i see no problem in that query.. what is the problem ?! btw, you can even make it smaller:
$DB_site->query("ALTER TABLE " . TABLE_PREFIX . "table ADD test int(10)");

Tekton
09-18-2004, 09:03 PM
PROBLEM SOLVED - Must use `21398` thingies around numbers.

<> <> <>
Invalid SQL: ALTER TABLE testtable
ADD test int(10) unsigned DEFAULT '0' NOT NULL

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 'test int(10) unsigned DEFAULT '0' NOT NULL' at line 2

mysql error number: 1064

( MySQL 4.0.20 )

__________

On smaller code:

Invalid SQL: ALTER TABLE testtable ADD test int(10)
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 'test int(10)' at line 1
_____________

UPDATE - Errors on normal SQL in phpmyadmin too... Can anyone just try it for the heck of it?

Error: 1064 SQLSTATE: 42000 (ER_PARSE_ERROR) Message: %s near '%s' at line %d

It works with 'test' as a name, but I guess you can't use numbers as a structure name?

_______________

MORE - If you put `these_things` around numbers it works in SQL

Zachery
09-18-2004, 10:21 PM
PROBLEM SOLVED - Must use `21398` thingies around numbers.


<> <> <>
Invalid SQL: ALTER TABLE testtable
ADD test int(10) unsigned DEFAULT '0' NOT NULL

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 'test int(10) unsigned DEFAULT '0' NOT NULL' at line 2

mysql error number: 1064

( MySQL 4.0.20 )

__________

On smaller code:

Invalid SQL: ALTER TABLE testtable ADD test int(10)
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 'test int(10)' at line 1
_____________

UPDATE - Errors on normal SQL in phpmyadmin too... Can anyone just try it for the heck of it?

Error: 1064 SQLSTATE: 42000 (ER_PARSE_ERROR) Message: %s near '%s' at line %d

It works with 'test' as a name, but I guess you can't use numbers as a structure name?

_______________

MORE - If you put `these_things` around numbers it works in SQL
are you using this in phpmyadmin?
$DB_site->query("ALTER TABLE " . TABLE_PREFIX . "table ADD test int(10)");
thats only in vBuletin files this would be used for a style

you would do this in phpmyadmin i think

ALTER TABLE PREFIX_table ADD test int(10);

Might be wrong but hopefully someone will tell me if im wrong or wrong.

Tekton
09-18-2004, 10:44 PM
I know to use normal SQL in phpmyadmin, but you need to use`` around names of fields that are numbers (like `1443` or `2` as a field name)