Jump to content

Archived

This topic is now archived and is closed to further replies.

DarthViper3k

MySQL being a pain in the ass

Recommended Posts

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

The error might be that you allready have a primary key defined ?

 

Otherwise the solution posted above should work.

 

P.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.