Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 01-08-2003, 04:18 PM
curley curley is offline
 
Join Date: Jul 2002
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default auto incriment

hi i have a prob.

i have a database table with 2 fields and i want them to auto increment.

right the problem is i am using this query

// here we are trying to add a name
if ($action=="addcomment") {




$comment_insert = $DB_site->query("INSERT INTO `name` (`nameid`, `comment`) VALUES (null, '$comment')");

it just updates all the comments to the same one so i end up with loads of the same name???

the thing is if i use it in phpmyadmin and do the same query but change (null, '$comment')"); to this (null, 'trevor')");

it puts a new line in with the id no and trevor

what am i doing wrong ??
Reply With Quote
  #2  
Old 01-08-2003, 04:21 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

if you use INSERT it doesn't update any lines, it inserts a new one, that's why the command is called insert

you should use UPDATE if you want to update

UPDATE name SET(comment='$comment')
Reply With Quote
  #3  
Old 01-08-2003, 04:46 PM
filburt1 filburt1 is offline
 
Join Date: Feb 2002
Location: Maryland, US
Posts: 6,144
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can also use REPLACE INTO instead of INSERT INTO to overwrite existing lines.
Reply With Quote
  #4  
Old 01-09-2003, 05:59 PM
curley curley is offline
 
Join Date: Jul 2002
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok so if i have you right then the insert one should put a new line in well it does that ok but then i have all the rest of them with the comment in them as well how do i get the rest to stay as they are..

what i get now is this in the picy

how do i get each line to be different
Attached Images
File Type: gif noidea.gif (73.1 KB, 0 views)
Reply With Quote
  #5  
Old 01-09-2003, 08:07 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

UPDATE name SET(comment='$comment') WHERE nameid=xx

replace the xx with the nameid of the uptodate line
Reply With Quote
  #6  
Old 01-10-2003, 04:57 PM
curley curley is offline
 
Join Date: Jul 2002
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

sorry but i dont know what this bit means nameid=xx..

i tried putting $nameid

then tried the last column number (21) but it still overwrites the lot
Reply With Quote
  #7  
Old 01-11-2003, 02:27 PM
curley curley is offline
 
Join Date: Jul 2002
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok i've sorted that bit out, i can now insert new lines with an id no but how do i use it now to display the newest line where i want to but leave the others as they were??

at the mo the only query i can get to work is this

//try name again
$getname=$DB_site->query_first("SELECT comment FROM name WHERE nameid=23");
$name=$getname[comment];

i have to put the id no in and then it wont go to the next one that i type in to put it into the next thread
Reply With Quote
  #8  
Old 01-12-2003, 12:31 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
$getname=$DB_site->query_first("SELECT comment FROM name ORDER BY nameid DESC LIMIT 1");
Reply With Quote
  #9  
Old 01-12-2003, 02:27 PM
curley curley is offline
 
Join Date: Jul 2002
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you are really great thank you very much for helping me i hope i can be as much help to someone sometime
Reply With Quote
  #10  
Old 01-12-2003, 03:16 PM
curley curley is offline
 
Join Date: Jul 2002
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok i have the name inputed now and getting a unique id everytime so i have a list..

now how would i allie the id of the newest name to the thread its supposed to be for??
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 01:19 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.04543 seconds
  • Memory Usage 2,257KB
  • Queries Executed 12 (?)
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
  • (1)bbcode_code
  • (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
  • (1)postbit_attachment
  • (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
  • postbit_attachment
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete