List:General Discussion« Previous MessageNext Message »
From:Andy Bakun Date:March 20 2004 7:28am
Subject:Re: *very* strange...
View as plain text  
On Sat, 2004-03-20 at 01:03, Chris Knipe wrote:
> Lo everyone,
> I'm *baffled* completely.... I've never seen something like this before.....
> :((((  I tried this exact query from PHP, Perl, as well as the MySQL
> thingy... They ALL give the same result - it must therefore be my table....
> ...
> mysql> INSERT INTO Accounts (Username, Password) VALUES
> (Username='username@realmname', Password='password');
> Query OK, 1 row affected (0.00 sec)
> mysql> SELECT * FROM Accounts WHERE Username='username@realmname';
> Empty set (0.00 sec)
> mysql>
> mysql> SELECT * FROM Accounts WHERE Username='0';
> +---------+----------+----------+----------+----------+
> | EntryID | Username | Password | isActive | isCapped |
> +---------+----------+----------+----------+----------+
> |      48 | 0        | 0        | y        | n        |
> +---------+----------+----------+----------+----------+
> 1 row in set (0.00 sec)
> There's my entry.  It's the row that was inserted, because I can see from
> the EntryID (Auto Increment).
> Now, WTF is wrong here...   Nevermind what the value is I send to Username /
> Password, Mysql *ALWAYS* replaces the data specified with a 0.  Needless to
> say, due to the UNIQUE keys, I dont ever get the data into my table.... :(((

You are using the wrong syntax for what you want to do.  What you want
is this:

insert into table (username, password) values ('username', 'password')

Skip out the "username=" and "password=" part.  What you are ending up
doing here is that the values portion of the insert statement, these two
Are being evaluated as comparison expressions.  Since the string
'password' does not equal the value of the column Password (although
this seems like an odd syntax to allow without a where clause), the
value of these two columns is zero.  Simplified, your query ends up
being (after the expressions are evaluated):

insert into table (username, password) values (0, 0)

because both of the expressions you put in the values evaluate to 0.

I hope this is clear enough.

Andy Bakun <abakun@stripped>

*very* strange...Chris Knipe20 Mar
  • Re: *very* strange...Chris Knipe20 Mar
    • Re: *very* strange...mos22 Mar
  • Re: *very* strange...Andy Bakun20 Mar
  • Re: *very* strange...Nitin Mehta20 Mar