Verbindungsaufbau und import
This commit is contained in:
parent
f58d1fba86
commit
cc4606f46e
3 changed files with 37 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
*.project
|
26
import.php
Normal file
26
import.php
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<title>Import</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'verbindungsaufbau.php';
|
||||||
|
$liste = file_get_contents("http://wortschatz.uni-leipzig.de/Papers/top10000en.txt");
|
||||||
|
$encoded = mb_convert_encoding($liste, 'UTF-8',mb_detect_encoding($liste, 'UTF-8, ISO-8859-1', true));
|
||||||
|
$wortarray = explode("\n", str_replace("'", "\'", $encoded));
|
||||||
|
$importliste = $rest = substr(implode("'),('", $wortarray), 0, -3);
|
||||||
|
if ($mysqli->query("INSERT IGNORE INTO `unileipzig-en` (wort) VALUES ('$importliste")) {
|
||||||
|
echo "Erfolgreich importiert";
|
||||||
|
} else {
|
||||||
|
echo "Es ist ein Fehler aufgetreten: ";
|
||||||
|
echo $mysqli->error;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</body>
|
||||||
|
</html>
|
10
verbindungsaufbau.php
Normal file
10
verbindungsaufbau.php
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
$mysqli = new mysqli("localhost", "root", "", "rechtschreibung"); //Mit MySQL verbinden
|
||||||
|
if ($mysqli->connect_error) {
|
||||||
|
echo "Verbindungsfehler: ". mysql_connect_error();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
if (!$mysqli->set_charset("utf8")) { //Zeichensatz auf UTF-8 setzen (Umlaute!)
|
||||||
|
echo "Fehler beim Laden von UTF-8";
|
||||||
|
}
|
||||||
|
?>
|
Reference in a new issue