Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-01-2006, 12:37 AM
kobescoresagain kobescoresagain is offline
 
Join Date: Feb 2005
Posts: 327
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default SQL error, tried to figure it out, but not sure why it isn't working

Okay here is the table layout
id int(8) No 0
name varchar(50) Yes NULL
dob varchar(50) Yes NULL
height varchar(50) Yes NULL
weight int(3) Yes 0
jersey varchar(50) Yes NULL
from varchar(50) Yes NULL
position varchar(50) Yes NULL
teamname varchar(50) Yes NULL
sport varchar(25) Yes NULL

Here is the mysql query
Code:
$query = "INSERT INTO add_temp_player (id, name, height, weight, jersey, from, position, teamname, sport) VALUES ($_POST[id2],'$_POST[name]','$_POST[height]',$_POST[weight],'$_POST[number]','$_POST[from]','$_POST[position]','$_POST[team]','$_POST[sport]')";
    $result = mysql_query($query) or die('Query failed: ' . mysql_error());
When I echo out the $query I get this
INSERT INTO add_temp_player (id, name, height, weight, jersey, from, position, teamname, sport) VALUES (59,'Larry Hughes',' 6-5',184,' 32',' St. Louis',' G','cavaliers','')

Here is the error
Query failed: 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 'from, position, teamname, sport) VALUES (591,'Luis Alicea','',0

The database is connected, because the other queries, on the same page work.

Which looks right to me. I am not sure why it isn't working, can anyone help me out.

Thanks
Reply With Quote
  #2  
Old 04-01-2006, 09:27 AM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
[high]from[/high], position, teamname,
you are using a mysql keyword within your query, which produces the error

i suggest to rename the field via phpmyadmin and change the query
Reply With Quote
  #3  
Old 04-01-2006, 01:21 PM
Code Monkey's Avatar
Code Monkey Code Monkey is offline
 
Join Date: May 2004
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, you can't use keywords.

On a side note, I notice some of the data has leading spaces. You might want to trim() your data before entry to remove leading and trailing spaces. They are usualy the result of copy/paste data entry into forms.
Reply With Quote
  #4  
Old 04-04-2006, 02:15 PM
kobescoresagain kobescoresagain is offline
 
Join Date: Feb 2005
Posts: 327
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, I will add that, I noticed that as well, just hadn't done it yet.
Reply With Quote
Reply


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 08:31 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.04518 seconds
  • Memory Usage 2,190KB
  • 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
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete