Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 04-06-2010, 10:55 PM
killa seven killa seven is offline
 
Join Date: Aug 2007
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default SQL synax problem

PHP Code:
$vbulletin->db->query_write("CREATE TABLE IF NOT EXISTS ".TABLE_PREFIX."`dbh_victims` (
`id` INT( 4 ) NOT NULL AUTO_INCREMENT ,
`username` VARCHAR( 45 ) NOT NULL ,
`beat` VARCHAR( 45 ) NOT NULL ,
`cscore` INT( 1 ) NOT NULL DEFAULT '0' ,
`oscore` INT( 1 ) NOT NULL DEFAULT '0'
UNIQUE (
`id`
"
); 
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 '(
'id'' at line 7
Error Number : 1064


im thinking that theres an extra comma some where near id
Reply With Quote
  #2  
Old 04-07-2010, 01:03 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

look at your last three lines.... now tell me where the ending ") is for the first line.
Reply With Quote
  #3  
Old 04-07-2010, 01:29 AM
killa seven killa seven is offline
 
Join Date: Aug 2007
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

what do you mean ending? i put an ending parentheses at the end of ") but still no go
Reply With Quote
  #4  
Old 04-07-2010, 01:35 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, so where is the ending paren to the UNIQUE ( that you have?
Reply With Quote
  #5  
Old 04-07-2010, 01:38 AM
killa seven killa seven is offline
 
Join Date: Aug 2007
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

oh ok
PHP Code:
$vbulletin->db->query_write("CREATE TABLE IF NOT EXISTS ".TABLE_PREFIX."`dbhVictims` (
`id` INT( 4 ) NOT NULL AUTO_INCREMENT ,
`username` VARCHAR( 45 ) NOT NULL ,
`beat` VARCHAR( 45 ) NOT NULL ,
`cscore` INT( 1 ) NOT NULL DEFAULT '0' ,
`oscore` INT( 1 ) NOT NULL DEFAULT '0'
UNIQUE (`id`)
"
); 
i put the paren after id no syntax errors but it isn't created in the database
Reply With Quote
  #6  
Old 04-07-2010, 02:27 AM
TigerC10's Avatar
TigerC10 TigerC10 is offline
 
Join Date: Apr 2006
Location: Austin, TX
Posts: 616
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You're still missing a closing parenthesis (from right after the dbhVictims), and you may also want to get rid of the ` symbol. In Perl the `operator performs a system command and PHP is supposed to be Perl embedded in HTML (but I'm unclear as to the status of the ` operator in PHP).

Try this instead...

PHP Code:
$vbulletin->db->query_write(
    
"CREATE TABLE IF NOT EXISTS ".TABLE_PREFIX."dbhVictims (
        id       INT( 4 )      NOT NULL AUTO_INCREMENT,
        username VARCHAR( 45 ) NOT NULL,
        beat     VARCHAR( 45 ) NOT NULL,
        cscore   INT( 1 )      NOT NULL DEFAULT 0,
        oscore   INT( 1 )      NOT NULL DEFAULT 0,
        PRIMARY KEY(id)
    )"
); 
Doing it this way (with the staggered indents) makes errors more obvious to see in the future.
Reply With Quote
  #7  
Old 04-07-2010, 02:28 AM
killa seven killa seven is offline
 
Join Date: Aug 2007
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yeagh i thought those tick marks looked weird...

edits..

its not going into the database for some reason
Reply With Quote
  #8  
Old 04-07-2010, 02:33 AM
TigerC10's Avatar
TigerC10 TigerC10 is offline
 
Join Date: Apr 2006
Location: Austin, TX
Posts: 616
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There's nothing wrong with the backticks in a MySQL command. I know of many .SQL files that use them. Using the ` operator can be confusing in Perl though. It's not required, so why put them in?
Reply With Quote
  #9  
Old 04-07-2010, 02:36 AM
killa seven killa seven is offline
 
Join Date: Aug 2007
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yeagh... its still not going into the database tho

there is actually no syntax errors now its just not going in when i upload the product
Reply With Quote
  #10  
Old 04-07-2010, 02:46 AM
TigerC10's Avatar
TigerC10 TigerC10 is offline
 
Join Date: Apr 2006
Location: Austin, TX
Posts: 616
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well it might have to do with the IF NOT EXISTS that you gave it. If you ran this code with the wrong syntax then it may have created an empty table. Then when you ran it a second time the empty table was there and it didn't issue the create statement again.

Whatever method you're using to view your database, you may be missing the table. Sometimes viewers sort based on the capital letters and the lower case letters. If it's a web-based viewer then you may need to close it down and open it again (browser cache could mess you up).
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:42 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04332 seconds
  • Memory Usage 2,251KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete