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-03-2004, 02:21 PM
burnist's Avatar
burnist burnist is offline
 
Join Date: Jul 2003
Location: Ireland
Posts: 72
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default help before i do something i may regret

I am runnig this query from a file

PHP Code:
$DB_site->query("INSERT INTO item_cats (name,battle,order,description) VALUES (' ".$_POST['itemcatname']." ',' ".$_POST['battleitemcat']." ',' "$_POST['catdisplayorder']." ',' "$_POST['itemcatdescription']." ')  "); 
The output should be a redirect page called on the next line(s) but instead i get the following error

Invalid SQL: INSERT INTO item_cats (name,battle,order,description) VALUES (' test ',' 1 ',' 1 ',' test ')
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 'order,description) VALUES (' test ',' 1 ',' 1 ',' test ')' at l

mysql error number: 1064

I have had some one on my msn list look over the query and they cannot find a problem with it. This is driving me insane and anyhelp would be greatly appreciated :tired:
Reply With Quote
  #2  
Old 04-03-2004, 02:27 PM
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Location: England
Posts: 9,071
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You don't need to quote numerical values.
Reply With Quote
  #3  
Old 04-03-2004, 02:42 PM
burnist's Avatar
burnist burnist is offline
 
Join Date: Jul 2003
Location: Ireland
Posts: 72
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

no luck, now i gives

Invalid SQL: INSERT INTO item_cats (name,battle,order,description) VALUES (' test ',1,1,' test ')
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 'order,description) VALUES (' test ',1,1,' test ')' at line 1

mysql error number: 1064
Reply With Quote
  #4  
Old 04-03-2004, 02:47 PM
assassingod's Avatar
assassingod assassingod is offline
 
Join Date: Jul 2002
Posts: 3,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You cant use 'order' as a column name. Change it
Reply With Quote
  #5  
Old 04-03-2004, 02:52 PM
burnist's Avatar
burnist burnist is offline
 
Join Date: Jul 2003
Location: Ireland
Posts: 72
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks assassingod, that worked straight away
Reply With Quote
  #6  
Old 04-03-2004, 02:53 PM
assassingod's Avatar
assassingod assassingod is offline
 
Join Date: Jul 2002
Posts: 3,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No problem
Reply With Quote
  #7  
Old 04-03-2004, 05:34 PM
burnist's Avatar
burnist burnist is offline
 
Join Date: Jul 2003
Location: Ireland
Posts: 72
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

now im having problems with mysql_fetch_array()


PHP Code:
$catfields $DB_site->query("SELECT id, name FROM " TABLE_PREFIX " item_cats");
    while (
$catinfo $DB_site->fetch_array($catfields))
    {
    echo
'<tr valign="top" align="center">
    <td class="alt1" align="left"><b>$catinfo[name]</b></a>&nbsp;</td>
    <td class="alt1"><a href="itemadmin.php?do=deloldcat&id=$catinfo[id]">Delete</a></td>
    <td class="alt1"><a href="itemadmin.php?do=editoldcat&id=$catinfo[id]">Edit</a></td>
    </tr>'
;    
    } 
This is showing the right number of rows (ie same number of rows as in that database but the text it shows is $catinfo[name] and i cant see why, as far as i can tell the variable have the same name etc (slightly dyslixic so dont hold me to that )
Reply With Quote
  #8  
Old 04-03-2004, 06:06 PM
filburt1 filburt1 is offline
 
Join Date: Feb 2002
Location: Maryland, US
Posts: 6,144
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

As an unrelated note, you have massive SQL injection issues. Use addslashes() for every string used in a query, no exceptions.
Reply With Quote
  #9  
Old 04-03-2004, 06:18 PM
burnist's Avatar
burnist burnist is offline
 
Join Date: Jul 2003
Location: Ireland
Posts: 72
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i assume you are talking about the first post? I probobly will later but its in the admin panel so its not really a hugh problem but i will update it in my file
Reply With Quote
  #10  
Old 04-03-2004, 11:47 PM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
This is showing the right number of rows (ie same number of rows as in that database but the text it shows is $catinfo[name] and i cant see why, as far as i can tell the variable have the same name etc (slightly dyslixic so dont hold me to that )
You must set a string with double quotes if you intend to include variables.

e.g.

PHP Code:
$name "$bbuserinfo[username]"
Single quotes if otherwise:

PHP Code:
$name 'John'
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 03:57 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.03987 seconds
  • Memory Usage 2,253KB
  • 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
  • (4)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (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_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