duplicated database insert
Posted: Sun Mar 19, 2006 8:04 am
hi, i'm having some trouble with a script that recieves some info through a form and inserts it into the db
after i run the script, i check my db and there are two entries with different keys ($tipoid) just as if the script had run twice.
tipoid | tipo | descripcion
***** | **** | **********
100TA1 | 1/4 pag BN | 1/4 de pagina Blanco y Negro
101TA1 | 1/4 pag BN | 1/4 de pagina Blanco y Negro
that's the result i get when i query the table after inserting what was supposed to be a single record...
thanks !!
Code: Select all
case'tipo_aviso':
$cant_tipos = ( mssql_fetch_row( mssql_query( 'SELECT count(tipoid) FROM md_tipo_aviso' ) ) );
if ( ( $cant_tipos[0] ) < 10 ) {
$cant = '10' . $cant_tipos[0];
} else {
$cant = '1' . $cant_tipos[0];
}
$tipo = $_POST['tipo'];
$tipoid = $cant . strtoupper( 'ta' . substr( $tipo, 0, 1 ) );
$descripcion = $_POST['descripcion'];
$query = ('BEGIN TRANSACTION
INSERT INTO md_tipo_aviso VALUES (\'' . $tipoid . '\',\'' . $tipo . '\',\'' . $descripcion . '\')
COMMIT TRANSACTION');
$result = mssql_query($query,$db->dblink);
mssql_close($db->dblink);
ob_clean();
header("Location: http://127.0.0.1/docek/tipo_aviso_back. ... escripcion");
break;tipoid | tipo | descripcion
***** | **** | **********
100TA1 | 1/4 pag BN | 1/4 de pagina Blanco y Negro
101TA1 | 1/4 pag BN | 1/4 de pagina Blanco y Negro
that's the result i get when i query the table after inserting what was supposed to be a single record...
thanks !!