Save ability... Duplicate DB entries

From: Date: Sat, 10 Aug 2002 15:44:53 +0000
Subject: Save ability... Duplicate DB entries
Groups: php.general 
Request: Send a blank email to php-general+get-111949@lists.php.net to get a copy of this message
i have this code snippet: if(isset($_POST['save'])){ $query = 'INSERT INTO article_data VALUES (\'\', '.$_SESSION['uid'].', '.time().', \''.$_POST['title'].'\', \''.$_POST['description'].'\', '.$_POST['cat'].', \''.$_POST['text'].'\', 0)'; $result = mysql_query($query) or die("Query failed: $query<br>" . mysql_error()); echo 'you saved your work.'; } elseif(isset($_POST['pub'])) { $query = 'INSERT INTO article_data VALUES (\'\', '.$_SESSION['uid'].', '.time().', \''.$_POST['title'].'\', \''.$_POST['description'].'\', '.$_POST['cat'].', \''.nl2br($_POST['text']).'\', 0)'; echo 'you published your work.'; } Which has a save or a publish option. I only want to keep one copy of each article in the DB. This adds a new one each time. I know about updates in SQL but the file may or may not already be in the db. Does anyone have a good way to go about this?

« previous php.general (#111949) next »