Jump to content

Unwanted Duplication


cjosephson

Recommended Posts

I am trying to add rows to my database via an online form, and when I submit it, even if my value for a column is the exact same as in a previously existing entry, the new value is considered unique.

I have mysql server version 5.0.38, and the command I am using is

 

$query = "insert into allsw2 (keyname, name, location, binder_or_shelf, row, number) values ('$GLOBALS[newkey]', '$name', '$location', '$binder', '$row1', '$number')";

mysql_query($query);

 

 

 

I have an online form to add entries to my database. I collect the variable, and trim whitespace from it using this code:

 

$number = trim($_POST['number']);

 

 

 

Unfortunately, something is remaining, and when I add an entry that has the same value in the number column as a previously existing entry, it is treated like a different number!

 

I use this command to select distinct records: "select distinct number from allsw2 order by (number+0)". Also, my data type for the column is varchar (I do entries like '1 thru 8', so this is necessary).

 

Why is my number showing up twice? Is there something else I need to do to the variable before I put it into the table?

Link to comment
https://forums.phpfreaks.com/topic/63721-unwanted-duplication/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.