vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Help with add field vb/php syntax (https://vborg.vbsupport.ru/showthread.php?t=69599)

Tekton 09-18-2004 05:54 PM

Help with add field vb/php syntax
 
PHP Code:

$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 , but none of them seem to work either.

Zachery 09-18-2004 08:16 PM

Quote:

Originally Posted by Tekton
PHP Code:

$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 , 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:
PHP Code:

 $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

Quote:

Originally Posted by Tekton
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)


All times are GMT. The time now is 11:16 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00968 seconds
  • Memory Usage 1,736KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete