my $chk_arid = "SELECT MAX( arid ) FROM $table where flag = ?"; my ($arid) = sql_query( $chk_arid , 1 ); # or my $cmd = "select aid, code from authors where name = ? "; ( $aid, $code ) = sql_query( $cmd, $name ); # or even my $cmd_up = "UPDATE SET flag = 0 where flag = 1 and arid = ?"; sql_query( $cmd_up, $pub{arid} ) or die("Error update flag"); my $cmd_ins = "INSERT INTO $table ( arid, catid, filename, title, aid, teaser, text, links, comment, changeby, newsid, keywords, description, flag) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; sql_query( $cmd_ins, $arid, $file, $pub{title}, $pub{aid}, $pub{teaser}, $pub{text}, $pub{links}, $comment, $aid, $pub{newsid}, $pub{keywords}, $pub{description}, 1 ) or die("Failed to insert new changed sql data :( \n");