Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.