Lines 106-118
if ($op eq 'add_form') {
Link Here
|
106 |
|
106 |
|
107 |
if ( $new_authorised_value =~ /^[a-zA-Z0-9\-_]+$/ ) { |
107 |
if ( $new_authorised_value =~ /^[a-zA-Z0-9\-_]+$/ ) { |
108 |
if ( $id ) { # Update |
108 |
if ( $id ) { # Update |
109 |
my $sth = $dbh->prepare( "SELECT category, authorised_value FROM authorised_values WHERE id='$id' "); |
109 |
my $sth = $dbh->prepare( "SELECT category, authorised_value FROM authorised_values WHERE id=? "); |
110 |
$sth->execute(); |
110 |
$sth->execute($id); |
111 |
my ($category, $authorised_value) = $sth->fetchrow_array(); |
111 |
my ($category, $authorised_value) = $sth->fetchrow_array(); |
112 |
if ( $authorised_value ne $new_authorised_value ) { |
112 |
if ( $authorised_value ne $new_authorised_value ) { |
113 |
my $sth = $dbh->prepare_cached( "SELECT COUNT(*) FROM authorised_values " . |
113 |
my $sth = $dbh->prepare_cached( "SELECT COUNT(*) FROM authorised_values " . |
114 |
"WHERE category = '$new_category' AND authorised_value = '$new_authorised_value' and id<>$id"); |
114 |
"WHERE category = ? AND authorised_value = ? and id <> ?"); |
115 |
$sth->execute(); |
115 |
$sth->execute($new_category,$new_authorised_value,$id); |
116 |
($duplicate_entry) = $sth->fetchrow_array(); |
116 |
($duplicate_entry) = $sth->fetchrow_array(); |
117 |
warn "**** duplicate_entry = $duplicate_entry"; |
117 |
warn "**** duplicate_entry = $duplicate_entry"; |
118 |
} |
118 |
} |
Lines 135-142
if ($op eq 'add_form') {
Link Here
|
135 |
} |
135 |
} |
136 |
else { # Insert |
136 |
else { # Insert |
137 |
my $sth = $dbh->prepare_cached( "SELECT COUNT(*) FROM authorised_values " . |
137 |
my $sth = $dbh->prepare_cached( "SELECT COUNT(*) FROM authorised_values " . |
138 |
"WHERE category = '$new_category' AND authorised_value = '$new_authorised_value' "); |
138 |
"WHERE category = ? AND authorised_value = ? "); |
139 |
$sth->execute(); |
139 |
$sth->execute($new_category,$new_authorised_value); |
140 |
($duplicate_entry) = $sth->fetchrow_array(); |
140 |
($duplicate_entry) = $sth->fetchrow_array(); |
141 |
unless ( $duplicate_entry ) { |
141 |
unless ( $duplicate_entry ) { |
142 |
my $sth=$dbh->prepare( 'INSERT INTO authorised_values |
142 |
my $sth=$dbh->prepare( 'INSERT INTO authorised_values |
143 |
- |
|
|