标签试图关闭,但我从未要求它这样做

时间:2015-01-28 17:51:18

标签: php

我已经制作了php文件来向我展示af .csv文件的内容。 就在它完成之前,我被告知该网站正在尝试关闭标签f我点击是它关闭,如果我点击没有预期结果显示。 但是我不打算这样做,那么是什么让程序这样做呢?

这是代码: - 任何人都可以帮助我吗? 提前谢谢。

<!DOCTYPE html>

<head>
<meta charset="UTF-8">
      <title>Opdel dankort bonner</title>
      <link rel="stylesheet" href="Stylesheet_hjemmeside.css" type="text/css"/>   
      </head>
      <body>

      <?php

      $server = "localhost";
$brugernavn = "root";
$kode = "password";
$db = "database";
$Taeller = -1;
$navn = $_GET["link"];
$sti= "/Data/Bankfiler/" . $navn;


$mysqli = new mysqli($server , $brugernavn , $kode, $db);

if (mysqli_connect_errno()) {
    echo 'Der opstod en fejl ved forbindelsen: ' . mysqli_connect_error(); 
    exit();
}

if (!$mysqli->set_charset("utf8")) {
    printf("Error loading character set utf8: %s\n", $mysqli->error);
} else {
}  

if ($stmt = $mysqli->prepare('DELETE FROM `dankorttrans`'))
    {
        $stmt->execute();
        $stmt->close();
    }

$csv = array(7);

$file= fopen($sti, "r");
while (($info = fgetcsv($file, 120, ";")) !==false)  {
    $csv[] = $info;
    $info = array_map("utf8_encode", $info); //added

    if ($info[2] === "Tekst") {
        goto hop;
    }

    $DK = substr($info[2], 0, 2);
    $aarmd = 201211;
    $kr_med_tegn = $info[4];
    $kr_uden_tusindtalssep =  (str_replace('.', ' ', $kr_med_tegn));
    $kr_punktum_isf_komma =  (str_replace(',', '.',$kr_uden_tusindtalssep ));
    $kr =  (str_replace(' ', '',$kr_punktum_isf_komma ));     

    if ($DK === "DK")
        {    
            $tekst43 = substr($info[2], 8, 43);
            $filtekst= $tekst43;
        }else{
        $tekst51 = substr($info[2], 0, 60);
        $filtekst= $tekst51;
    }

    if ($stmt = $mysqli->prepare('INSERT INTO `dankorttrans`(Dato, Tekst, Belob) VALUES (?, ?, ?)'))
        {
            $stmt->bind_param('isi', $Dato, $Tekst, $Belob);

            $Dato = $aarmd;
            $Tekst = $filtekst;
            $Belob = $kr;
            $stmt->execute();
            $stmt->close();
        hop:

        }   else {

        echo 'Der opstod en fejl i formularen: ' . $mysqli->error;
    }
} 
fclose($file);

if ($stmt = $mysqli->prepare('INSERT INTO `dankorttrans`(Dato, Tekst, Belob)  (?, ?, ?)'))
    {
        $stmt->bind_param('isi', $Dato, $Tekst, $Belob);
        $filtekst= " ";
        $kr = 0;
        $Dato = $aarmd;
        $Tekst = $filtekst;
        $Belob = $kr;
        $stmt->execute();
        $stmt->close();
    }   else {

    echo 'Der opstod en fejl i formularen: ' . $mysqli->error;
}

echo "<script>window.close();</script>";


$orden = "Tekst";

if ($stmt = $mysqli->prepare('SELECT `Dato`,`Tekst`, `Belob` from dankorttrans ORDER BY ' . $orden)) 
    { 

        $stmt->execute();
        $stmt->bind_result($Dato, $Tekst, $Belob);


        // Tabel overskrift
        echo "<table style=\"border-style: solid;border-width: thin;border- collapse: collapse;position: fixed;top:0px\">";
        echo "<tr><th style=\"border-style: solid;border-width: thin;border-collapse: collapse;color: darkred;background-color:palegoldenrod;font-size:     22px;width:53px;position: fixed;top:0px\">";
        echo "Dato";
        echo "</th><th style=\"padding-left:60px;text-align:left;border-style: solid;border-width: thin;border-collapse: collapse;color: darkred;background-color:palegoldenrod;font-size: 22px;width:456px\">";
        echo "Tekst";
        echo "</th><th style=\"padding-left:10px;text-align:left;border-style: solid;border-width: thin;border-collapse: collapse;color: darkred;background-color:palegoldenrod;font-size: 22px;width:120px\">";
        echo "Beløb";
        echo "</th></tr>";

        // Hent rækker og udskriv data 
        while ($stmt->fetch()) 
            {
                // formater output med decimalkomma og tusindtalsseperator
                $Belob_format = number_format($Belob, 2, ',', '.');

                // selve tabellen
                echo "<table style=\"border-style: solid;border-width: thin;border-collapse: collapse;\">";
                echo "<tr><td style=\"text-align:right;border-style: solid;border-width: thin;border-collapse: collapse;background-color:lightblue;width:51px\">";
                echo $Dato;
                echo "</td><td style=\"padding-left:10px;border-style: solid;border-width: thin;border-collapse: collapse;background-color:pink;width:450px\">";
                echo $Tekst;
                echo "</td><td style=\"text-align: right;padding-right:10px;border-style: solid;border-width: thin;border-collapse: collapse;background-color:lightblue;width:120px\">";
                echo $Belob_format;

                echo "</td></tr>";
                echo "</table>";
            }
        //* Luk statement 
        $stmt->close();

    }   else {
    // Der er opstået en fejl 
    echo 'Der opstod en fejl i erklæringen: ' . $mysqli->error;
} 
?>

</body>
</html>

1 个答案:

答案 0 :(得分:3)

我认为这一行可能就是问题!

echo "<script>window.close();</script>";

尝试解决这个问题。