Send to MYSQL Database -SOLVED

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

minorDemocritus
Forum Commoner
Posts: 96
Joined: Thu Apr 01, 2010 7:28 pm
Location: Chicagoland, IL, USA

Re: Send to MYSQL Database

Post by minorDemocritus »

mfandel wrote: The insert is failing because the ID value has to be unique and by default every query your form generates uses the same key value (127). Since there is already an entry in the database with the same value, MySQL refuses to overwrite it.
The problem is with the TINYINT data type in your table. Check here: http://dev.mysql.com/doc/refman/5.0/en/ ... types.html . Notice that the maximum value for signed TINYINT is 127. To fix this, edit the table structure, and change the ID field's type to SMALLINT or MEDIUMINT. You could also specify it to be UNSIGNED, so you're not potentially wasting half the range.

I don't really see why the form itself would be using the same key value... I can't find any mention of ID in the script!

Also, that section of the MySQL manual says:
http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html wrote:Integer or floating-point data types can have the additional attribute AUTO_INCREMENT. When you insert a value of NULL (recommended) or 0 into an indexed AUTO_INCREMENT column, the column is set to the next sequence value.
So you probably want to add the ID field in your query, just set it's value to NULL.
mfandel
Forum Newbie
Posts: 10
Joined: Fri Apr 02, 2010 12:48 am

Re: Send to MYSQL Database

Post by mfandel »

That was it!
You all are the best!
It was simply that tinyint...WHOOHOOO.
Though took a long round about to get there I learned a lot!
Thanks again
minorDemocritus
Forum Commoner
Posts: 96
Joined: Thu Apr 01, 2010 7:28 pm
Location: Chicagoland, IL, USA

Re: Send to MYSQL Database

Post by minorDemocritus »

Glad to hear it. It'd be nice if you edited your first post to add SOLVED to the title.
lunarnet76
Forum Commoner
Posts: 67
Joined: Sun Apr 04, 2010 2:07 pm
Location: Edinburgh

Re: Send to MYSQL Database

Post by lunarnet76 »

in case tinyint(100) does not mean anything more than tinyint(3) as the number cannot be more than 127 !
minorDemocritus
Forum Commoner
Posts: 96
Joined: Thu Apr 01, 2010 7:28 pm
Location: Chicagoland, IL, USA

Re: Send to MYSQL Database

Post by minorDemocritus »

lunarnet76 wrote:in case tinyint(100) does not mean anything more than tinyint(3) as the number cannot be more than 127 !
Right. The "length" of an INT or FLOAT field is merely the display width: it governs how many spaces MySQL will pad the output when it is retrieved from the DB.
Post Reply