$sql = "INSERT INTO ? VALUES (?)"; $std = $dbh->prepare($sql) or die("Could not prepare! At table = $table_name because " . $dbh->errstr); for $t (0 .. 1000) { $table_name = r.$tables[$t]; $theValue = $values[$t]; $std->execute($table_name , $theValue) or die("Could not execute!" . $dbh->errstr); }