DarthViper3k Posted May 12, 2003 Share Posted May 12, 2003 ok... If any of you know about my phpsystem I\'ve been making then you know what it is already.... if you don\'t know.... then don\'t worry about it I\'ve got a beta version of my phpsystem all made on my computer and it runs just fine now... I\'m trying to set it up for a school, but their database is being a pain in the ass I\'ve got my database almost completely set up but each time I try to put in the id fields for users, news, etc I get errors and whenever I do get my id field going... it doesn\'t work I\'ve done it before so I do know how to do it but it just isn\'t workin here is their database just not good enough or what? ALTER TABLE `news` ADD `id` VARCHAR( 15 ) NOT NULL FIRST ; the id field is in but now... how exactly do I go about givin each news post a new id when its posted? I look at my php code and it works at home just not on the school site Quote Link to comment https://forums.phpfreaks.com/topic/460-mysql-being-a-pain-in-the-ass/ Share on other sites More sharing options...
barbatruc Posted May 12, 2003 Share Posted May 12, 2003 Use AUTO_INCREMENT so your field \"id\" will get a new value for each INSERT you do. Also make your id an Int (unsigned by preferences) so it may increment for each insert query. ALTER TABLE `news` ADD `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST; Voilà! JP. Quote Link to comment https://forums.phpfreaks.com/topic/460-mysql-being-a-pain-in-the-ass/#findComment-1561 Share on other sites More sharing options...
DarthViper3k Posted May 12, 2003 Author Share Posted May 12, 2003 thats just it I knew bout the auto_incrament but every time I turn it on I get an error and using it is the ONLY time I get an error edit: and its really pissing me off Quote Link to comment https://forums.phpfreaks.com/topic/460-mysql-being-a-pain-in-the-ass/#findComment-1565 Share on other sites More sharing options...
pallevillesen Posted May 13, 2003 Share Posted May 13, 2003 The error might be that you allready have a primary key defined ? Otherwise the solution posted above should work. P. Quote Link to comment https://forums.phpfreaks.com/topic/460-mysql-being-a-pain-in-the-ass/#findComment-1579 Share on other sites More sharing options...
DarthViper3k Posted May 13, 2003 Author Share Posted May 13, 2003 I don\'t allready have a primary key defined thats whats confusing me and its driving me insane but since it wont auto_incriment could I like bring down the id value from the last item add one to it then just load up another number?? I dunno I\'m lost here I keep gettin this as my error Incorrect column specifier for column \'id\' what do I do?? I\'ve got to get this up ASAP there are students that depend on updating the website with news for their grades Quote Link to comment https://forums.phpfreaks.com/topic/460-mysql-being-a-pain-in-the-ass/#findComment-1585 Share on other sites More sharing options...
pallevillesen Posted May 14, 2003 Share Posted May 14, 2003 Ok, we need some info... Show the code causing the error and preferably a dump of the table structure as well... (Do a DESCRIBE table call or something similar)... I\'m not sure if you\'re trying to SET the id number which is autoincreasing or not... I would NOT make my own \"auto_increment\" function, since it could make problems, when multiple users were logged on simultaneously. P. Quote Link to comment https://forums.phpfreaks.com/topic/460-mysql-being-a-pain-in-the-ass/#findComment-1588 Share on other sites More sharing options...
DarthViper3k Posted May 14, 2003 Author Share Posted May 14, 2003 I don\'t have access to the database from here however I\'m not making my OWN autoincrement function I\'m using PHPMyAdmin and using the autoincrement function in the id field and I\'m wondering how would using that function give problems when multiple users are logged on all it does is give an id number when the account is created/writen to the database they would have completely different ID numbers and session numbers so logicaly there would be absolutely no problems so what your sayin makes no sense anyways what I\'m tryin to do is have an id field for my news and users and when their account or when the news is writen into the database it gets its own unique id number Quote Link to comment https://forums.phpfreaks.com/topic/460-mysql-being-a-pain-in-the-ass/#findComment-1589 Share on other sites More sharing options...
pallevillesen Posted May 15, 2003 Share Posted May 15, 2003 What I said was that if you try to SET id VALUES (2); it would probably fail, i.e. trying to specify the value that should be inserted into an autoincrementing field... Anyway, I still don\'t get it completely, so please spell it out... What and HOW are you trying to insert. I.i. are you trying to insert a new record using PHPmyAdmin or a phpscript of your own? (in the last case, please post the 4 important lines of code). Also, if you can acces the DB using phpmyadmin, then try and execute a DESCRIBE tblname and post the output, just to check the table structure... P. Quote Link to comment https://forums.phpfreaks.com/topic/460-mysql-being-a-pain-in-the-ass/#findComment-1590 Share on other sites More sharing options...
DarthViper3k Posted May 15, 2003 Author Share Posted May 15, 2003 I\'m NOT EVEN TRYING to insert data yet I\'m just trying to set up the damn id field heres what it shows for the id field id varchar(15) PRI what I was trying to do was create an id field with PHPMyAdmin and each time I selected auto_increment it would give me an error take a look at PHPMyAdmin under the extra area and thats what I used it works at home on my database no clue why it wont work here again I\'ve got to get this up ASAP there are students that depend on updating the website with news for their grades edit: ok this pisses me off I copied 1 lione of code for useid from the membership tutorial I got error so I copied the whole create table function from that page into our test table it worked so now... WTF am I doin wrong? edit2: the most obvious idea wasn\'t in front of my face till now start over I\'m not sure what I did wrong but I started over and it works now *shrugs* its weird Quote Link to comment https://forums.phpfreaks.com/topic/460-mysql-being-a-pain-in-the-ass/#findComment-1594 Share on other sites More sharing options...
pallevillesen Posted May 16, 2003 Share Posted May 16, 2003 Ok, if it works now - then forget about why... Have a nice weekend P. Quote Link to comment https://forums.phpfreaks.com/topic/460-mysql-being-a-pain-in-the-ass/#findComment-1597 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.