rhyspaterson Posted July 3, 2007 Share Posted July 3, 2007 Hey guys, I'm trying to put together an INSERT command wherein a person can submit a record into the database through a HTML form. However i want to make sure the data is not already in there (stopping duplicates). The table has four columns; id, extension, description and filetype_group I want to match my variable $fileExtension (which is the $_POST variable from the form) against everything in the 'extension' column. So far i have come up with this: $result = pg_exec ($dbconn, "INSERT into filetype (id, extension, description, filetype_group) VALUES ($fileID,'$fileExtension','$fileDescription','$fileGroup') WHERE not exists (SELECT * FROM filetype WHERE filetype.extension = $fileExtension);"); The code works fine up until the WHERE not exists section, where i get syntax errors, but unfortunately i have no idea what's wrong. I was hoping you guys could shed some light. Cheers, /Rhys Quote Link to comment Share on other sites More sharing options...
rhyspaterson Posted July 3, 2007 Author Share Posted July 3, 2007 Primary key for 'filetype' table is the 'id' column. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.