Why does this not work?
No error show, but also no data added to the MySQL :/
The echo $Artikelgroep does show the Artikelgroep's.
Basicly (for now) I want to dump all the "Artikelgroep"'s in to the database named: "testdb", table: "categories_description", field: "categories_name"
Code:
<?php
// Set Mysql Variables
$host = 'localhost';
$user = 'root';
$pass = 'i-have-removed-it';
$db = 'testdb';
$table = 'categories_description';
$file = "/var/www/web1/web/handel/test/testdb.txt";
$fp = fopen($file, "r");
$data = fread($fp, filesize($file));
fclose($fp);
$output = str_replace("\t|\t", "|", $data);
$output = explode("\n", $output);
mysql_connect($host,$user,$pass) or die(mysql_error());
foreach($output as $var) {
$tmp = explode("|", $var);
$Artikelcode = $tmp[0];
$Leverancierscode = $tmp[1];
$Omschrijving = $tmp[2];
$Adviesprijs = $tmp[3];
$Bruto_prijs = $tmp[4];
$Voorraad = $tmp[5];
$Artikelgroep = $tmp[6];
$Prijsgroep = $tmp[7];
$Kortings_percentage = $tmp[8];
$Selectiecode = $tmp[9];
$Selectiecode_omschrijving = $tmp[10];
$UNSPSC_code = $tmp[11];
$Standaard_nalevertijd = $tmp[12];
echo $Artikelgroep . "<br>";
$sql = "INSERT INTO $table SET categories_name='$Artikelgroep'";
mysql_query($sql);
}
echo "Done!";
?>
The MySQL looks like this:
Code:
CREATE TABLE `categories_description` (
`categories_id` int(11) NOT NULL default '0',
`language_id` int(11) NOT NULL default '1',
`categories_name` varchar(32) NOT NULL default '',
PRIMARY KEY (`categories_id`,`language_id`),
KEY `idx_categories_name` (`categories_name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;