diff --git a/components/pastebin.php b/components/pastebin.php
index 6cdb785a4105a86ddabccadb525a9a81f9e5dd95..dbf91546ab14d899cf04a468861c3f81c3d5a617 100755
--- a/components/pastebin.php
+++ b/components/pastebin.php
@@ -163,12 +163,11 @@ if (isset($_POST['code'])) {
 		} else {
 			// Additional user validation needed here
 			//$retainTil = date('Y/m/d H:i:s', time() + $retain);
+			$id = $DB->GetOne("SELECT nextval('pastebin_id_seq'::regclass)");
 			$DB->Execute(
-				'INSERT INTO ' . _TABLE_NAME . ' ( code, username, retain_til, language) ' .
-				'VALUES (?, ?, ?, ?)', 
-				array( $code, $session->username, $retainTil, $pblang));
-			//$id = $DB->Insert_ID();
-			$id = $DB->GetOne('SELECT id FROM ' . _TABLE_NAME . ' WHERE code = ? AND username = ? AND retain_til = ?', array($code,$session->username,$retainTil));
+				'INSERT INTO ' . _TABLE_NAME . ' ( id, code, username, retain_til, language) ' .
+				'VALUES (?, ?, ?, ?, ?)', 
+				array( $id, $code, $session->username, $retainTil, $pblang));
 			$userInfo = 'Created By ' . $session->username . ' at ' . date('Y/m/d H:i');
 			$smarty->assign('id', $id);
 			$smarty->assign('userInfo', $userInfo);