Re: I'm confused



Ok, I hear you on the uid part.

The table right now only has 30 rows, so i can see that the there. This also
will not account why adding user
'uuuuuueeeeierirerieureiureiruierueiurieurieurie' returns as already
existing?

The problem is not that the query is not working, the problem is that is IS
working, but returning false.


"J.O. Aho" <user@xxxxxxxxxxx> wrote in message
news:4kjho9FcihooU1@xxxxxxxxxxxxxxxxx
_Raven wrote:

Ok, the table is like so:
id auto_increment, not null, primary_key
uid int(5)
name varchar(255) not null

Okey, I don't know why you have both id and uid?
In your example it seems like uid=id+31 and you seem to calculate it in
your php code, why not use auto_increment and start it from 31 instead of
0?


SAMPLE DATA IN TABLE:
1, 32, bill
2, 33, fred
3, 34, mark
4, 35, ralph
5, 36, jerry

$sql = "INSERT INTO mytable (uid,name) VALUES ('" . $nextUID . "','" .
$_GET['name'] . "')";
$query = mysql_query($sql);

'" . $nextUID . "'
I wouldn't use this for an column where I have INT, I would just done
" . $nextUID . "
Not sure if this causes the problem for you, and I wouldn't use a $_GET
directly into a sql query, I would first check that the data is valid
before inject it into the query statement.


#OUTPUT FROM ABOVE:

COULD NOT ADD Joe! The error was: Duplicate entry 'joe' for key 2
The SQL was: INSERT INTO mytable (uid,name) VALUES (41,'joe')

Affected Rows: -1

This does indicate that you would have something already in your table
that you try to add, you maybe should redesign your table a bit, drop the
uniques for testing purposes and see if your table works better.
You could also print out the whole table too, so that you can verify that
you don't have data already in it that does affect the insert.


Are all columns unique? then you limit quite much what you can enter
into your table, only the uid should be unique and a primary key.

No, only the name column is unique, except for the id col, which is
primary key and unique by default I believe

Yes, primary keys does give uniques to columns by default.


//Aho


.



Relevant Pages

  • RE: "The operation was cancelled at the users request" error during mass insertions
    ... | I am doing the insertions in a for loop, ... | setNextUid(nextUID); //update nextUid in the table Uid ... The error message suggests that the query being executed is simply taking ...
    (microsoft.public.sqlserver.jdbcdriver)
  • Re: Bizarre subquery syntax problem
    ... With Access, the official syntax for a subquery always requires an alias, so ... SELECT p.AS UID, p.Firstname AS Firstname, p.Lastname AS Lastname, ... I am seeing bizarre problems with a subquery. ... core query runs fine- ...
    (microsoft.public.access.queries)
  • Re: Narrowing a QR Results Set
    ... a good practice is to query the Worklist SCP for the Scheduled Station ... Another implementation, query all for the specific modality type, is ... Parsing UIDs is the straight road to hell, ...
    (comp.protocols.dicom)
  • Re: Performance: Query optimizer producing sub-optimal result?
    ... Have you tried adding the query hint OPTION to your query ... Mark Ayliffe wrote: ... > SELECT UID, fnCheck ... > once per record in MyTable, not once per DISTINCT MainPart as I'd expected. ...
    (microsoft.public.sqlserver.programming)
  • Re: Im confused
    ... Not sure if this causes the problem for you, and I wouldn't use a $_GET directly into a sql query, I would first check that the data is valid before inject it into the query statement. ... Affected Rows: -1 ... only the uid should be unique and a primary key. ... No, only the name column is unique, except for the id col, which is primary key and unique by default I believe ...
    (alt.php)