46 lines
1.5 KiB
PHP
46 lines
1.5 KiB
PHP
<?php
|
|
|
|
//ini_set("memory_limit","1024M");
|
|
//set_time_limit(60000);
|
|
|
|
// get data
|
|
// connect import database
|
|
|
|
// database
|
|
/*$connection=mysql_connect('localhost', 'root', '1234') or die ("Verbindungsversuch fehlgeschlagen");
|
|
mysql_select_db('intelectra_shop__', $connection) or die("Konnte die Datenbank nicht waehlen.");*/
|
|
|
|
$connection = mysql_connect('localhost', 'int-db-sql-shop', 'Msc7t24?381L') or die("Verbindungsversuch fehlgeschlagen");
|
|
mysql_select_db('webshop-sql', $connection) or die("Konnte die Datenbank nicht waehlen.1");
|
|
|
|
$query = mysql_query('SELECT * FROM customer_addresses where house_number = ""') or die("Anfrage nicht erfolgreich");
|
|
$data = array();
|
|
while($obj = mysql_fetch_object($query)) {
|
|
$street = $obj->street;
|
|
// trenne strings
|
|
$length = strlen($street);
|
|
$found = -1;
|
|
for ($z=0;($found == -1 && $z<$length);$z++) {
|
|
if (is_numeric(substr($street,$z,1))) {
|
|
$found = $z;
|
|
}
|
|
}
|
|
|
|
if ($found != -1) {
|
|
$street_new = trim(substr($obj->street,0,$found));
|
|
$house_number = trim(substr($obj->street,$found,($length - $found)));
|
|
|
|
$sql = "
|
|
UPDATE customer_addresses
|
|
SET
|
|
street = '".mysql_real_escape_string($street_new)."',
|
|
house_number = '".mysql_real_escape_string($house_number)."'
|
|
WHERE id=".$obj->id."
|
|
";
|
|
// echo "<br>$street<br>".$sql;
|
|
mysql_query($sql);
|
|
}
|
|
}
|
|
|
|
|
|
?>
|