Jump to content

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

Link to comment
https://forums.phpfreaks.com/topic/460-mysql-being-a-pain-in-the-ass/
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.

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

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.

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

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.

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.