Jump to content


Photo

MySQL being a pain in the ass


  • Please log in to reply
9 replies to this topic

#1 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 12 May 2003 - 03:58 PM

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
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.

#2 barbatruc

barbatruc
  • Members
  • PipPip
  • Member
  • 28 posts
  • LocationMontreal, Quebec, Canada

Posted 12 May 2003 - 05:09 PM

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.
Unfortunately, PHP \'empowered every moron with a copy of Windows notepad to be \"web programmers\". (...) Give PHP a real INFRASTRUCTURE. Use PEAR!!!\'

#3 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 12 May 2003 - 09:05 PM

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
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.

#4 pallevillesen

pallevillesen
  • Members
  • PipPipPip
  • Advanced Member
  • 135 posts
  • LocationDenmark

Posted 13 May 2003 - 09:18 AM

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

Otherwise the solution posted above should work.

P.
Palle Villesen, www.birc.dk [br]Bioinformatics Research Center

#5 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 13 May 2003 - 05:45 PM

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
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.

#6 pallevillesen

pallevillesen
  • Members
  • PipPipPip
  • Advanced Member
  • 135 posts
  • LocationDenmark

Posted 14 May 2003 - 09:04 AM

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.
Palle Villesen, www.birc.dk [br]Bioinformatics Research Center

#7 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 14 May 2003 - 10:01 PM

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
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.

#8 pallevillesen

pallevillesen
  • Members
  • PipPipPip
  • Advanced Member
  • 135 posts
  • LocationDenmark

Posted 15 May 2003 - 07:30 AM

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.
Palle Villesen, www.birc.dk [br]Bioinformatics Research Center

#9 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 15 May 2003 - 04:39 PM

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
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.

#10 pallevillesen

pallevillesen
  • Members
  • PipPipPip
  • Advanced Member
  • 135 posts
  • LocationDenmark

Posted 16 May 2003 - 09:16 AM

Ok, if it works now - then forget about why... Have a nice weekend :)

P.
Palle Villesen, www.birc.dk [br]Bioinformatics Research Center




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users