[thelist] PHP: Insert or Replace (upon duplicate IP) - Alter and mySQL syntax

AtdtXav atdtxav at yahoo.com
Tue Apr 9 13:30:01 CDT 2002


Thanks Rudy,

It doesn't sound right to me either, here's what I get when I
try to insert a new field -

MySQL said: alter command denied to user: 'atdt1991 at localhost'
for table 'ptmratings'

I get THIS if I try to create a table with a TEXT field called
"ip" that is set to unique -

CREATE TABLE testing (id SMALLINT UNSIGNED  not null
AUTO_INCREMENT, ip TEXT  not null , host TEXT  not null , email
TEXT  not null , comment TEXT  not null , rating TINYINT
UNSIGNED  not null , user_agent TEXT  not null  , PRIMARY KEY
(id), INDEX (id), UNIQUE (id, ip)) comment = 'test table'

MySQL said: BLOB column 'ip' used in key specification without a
key length

AND FINALLY I get this if I try to put in a key length of, say,
15 (15 characters for an IP, I figure)

MySQL said: You have an error in your SQL syntax near '(15) not
null , host TEXT not null , email TEXT not null , comment TEXT
not ' at line 1

Do I need to include something else instead of just a number for
the key length in this circumstance?

Thanks :)
Scott Kennedy

--- rudy <r937 at interlog.com> wrote:
> you can have only one unique key on a mysql table?
>
> doesn't sound right
>
>     CREATE INDEX is mapped to an ALTER TABLE statement
>     to create indexes. See section 6.5.4 ALTER TABLE Syntax.
>
>     Normally, you create all indexes on a table at the time
> the table
>     itself is created with CREATE TABLE. See section 6.5.3
> CREATE
>     TABLE Syntax. CREATE INDEX allows you to add indexes to
> existing
> tables.
>
>      http://www.mysql.com/doc/C/R/CREATE_INDEX.html
>
> maybe there's a problem with ALTER on evolt's server
>
> try dropping and then recreating the table with all indexes
>
> the way to handle your duplicate problem is simply to go ahead
> and do the
> insert
>
> if it fails, it was a duplicate
>
> not sure how to trap that if you need to display a result
> message
>
>
> rudy
>
> --
> For unsubscribe and other options, including
> the Tip Harvester and archive of thelist go to:
> http://lists.evolt.org Workers of the Web, evolt !


__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/



More information about the thelist mailing list