<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);	

// old database
$connection=mysql_connect('localhost', 'root', '1234') or die ("Verbindungsversuch fehlgeschlagen");
mysql_select_db('intelectra_shop__', $connection) or die("Konnte die Datenbank nicht waehlen.1");
/*
echo "get data<br>";
// get items
$query = mysql_query('SELECT * FROM import_kundenemail') or die("Anfrage nicht erfolgreich");
$data = array();
while($obj = mysql_fetch_object($query)) {
	$data[] = $obj;
}

echo "imports email<br>";
foreach ($data as $object) {
        if ($object->email) {
		$sql = "
			UPDATE customers
			SET
				email=\"".$object->email."\"
                        WHERE number='".$object->knr."'
		";
		$query = mysql_query($sql);
		if (!$query) {
			echo $sql;
			echo "<br />";
		}
        }
}

echo "ende<br>";

// get items
$query = mysql_query('SELECT * FROM import_kundenpasswort') or die("Anfrage nicht erfolgreich");
$data = array();
while($obj = mysql_fetch_object($query)) {
	$data[] = $obj;
}

echo "imports passwoerter<br>";
foreach ($data as $object) {
        if ($object->kennwort) {
		$sql = "
			UPDATE customers
			SET
				pass=\"".md5($object->kennwort)."\"
                        WHERE number='".$object->knr."'
		";
		$query = mysql_query($sql);
		if (!$query) {
			echo $sql;
			echo "<br />";
		}
        }
}

echo "ende<br>";

*/
echo "get data<br>";
// get items
$query = mysql_query('SELECT * FROM import_kundenzahlungen') or die("Anfrage nicht erfolgreich");
$data = array();
while($obj = mysql_fetch_object($query)) {
	$data[] = $obj;
}

echo "imports Zahlungsart<br>";
foreach ($data as $object) {
        if ($object->Zahlungsart) {
		$sql = "
			UPDATE customers
			SET
				freetextfield3=\"".$object->Zahlungsart."\"
                        WHERE number='".$object->Kundennummer."'
		";
		$query = mysql_query($sql);
		if (!$query) {
			echo $sql;
			echo "<br />";
		}
        }
}

echo "ende<br>";

?>