Einzelnen Beitrag anzeigen
  #2  
Alt 15.03.2016, 16:12:42
Bengelbaer Bengelbaer ist offline
Anfänger
 
Registriert seit: Mar 2016
Alter: 44
Beiträge: 2
AW: Datenübergabe Array -> Datenbank

Konnte es nun selbst lösen.

PHP-Code:
foreach ($xmlstr->Items->Item as $row) {
        
$date date("Y-m-d H:i:s");
        
$MainCategorie $row->Main_ProductGroup;

                
$queryMainKat "INSERT INTO `s_categories` (`id`, 
                                                            `parent`,
                                                            `path`,
                                                            `description`,
                                                            `position`,
                                                            `left`,
                                                            `right`,
                                                            `level`,
                                                            `added`,
                                                            `changed`,
                                                            `metakeywords`,
                                                            `metadescription`,
                                                            `cmsheadline`,
                                                            `cmstext`,
                                                            `template`,
                                                            `noviewselect`,
                                                            `active`,
                                                            `blog`,
                                                            `showfiltergroups`,
                                                            `external`,
                                                            `hidefilter`,
                                                            `hidetop`,
                                                            `mediaID`,
                                                            `product_box_layout`,
                                                            `meta_title`,
                                                            `stream_id`)

                                                            VALUES 
                                                            
                                                            ('',
                                                            '"
.$hauptKatId."',
                                                            '|"
.$hauptKatId."|',
                                                            '"
.$MainCategorie."',
                                                            NULL,
                                                            '0',
                                                            '0',
                                                            '0',
                                                            '"
.$date."',
                                                            '"
.$date."',
                                                            NULL,
                                                            '',
                                                            '',
                                                            '',
                                                            'article_listing_4col.tpl',
                                                            '0',
                                                            '1',
                                                            '0',
                                                            '1',
                                                            '',
                                                            '0',
                                                            '0',
                                                            NULL,
                                                            'basic',
                                                            '',
                                                            NULL )"
;
                if (
$conn->query($queryMainKat) === TRUE) {
                    echo 
"New record created successfully";
                    } else {
                    echo 
"Error: " $queryMainKat "<br>" $conn->error;}

                
$MainKatId "Select `id` from `s_categories` where `description` = '$MainCategorie'";
                if (
$conn->query($MainKatId) === TRUE) {
                    echo 
"New record found successfully";
                    } else {
                    echo 
"Error: " $MainKatId "<br>" $conn->error;}

                
$queryMainKat_attr "INSERT INTO `s_categories_attributes` (`id`,`categoryID`,`attribute1`,`attribute2`,`attribute3`,`attribute4`,`attribute5`,`attribute6`) VALUES (NULL,'".$MainKatId."','','','','','','' )";
                if (
$conn->query($queryMainKat_attr) === TRUE) {
                    echo 
"New record created successfully";
                    } else {
                    echo 
"Error: " $queryMainKat_attr "<br>" $conn->error;}
                 
                echo 
$conn->error;
                
///Durchlaufbegrenzung                        
                    
if ($i==3) break;
                    
$i++;    
}; 

immer diese `````````````````````````


nur hier hakt jetzt noch etwas

PHP-Code:
                $MainKatId "Select `id` from `s_categories` where `description` = '$MainCategorie'"
                if (
$conn->query($MainKatId) === TRUE) { 
                    echo 
"New record found successfully"
                    } else { 
                    echo 
"Error: " $MainKatId "<br>" $conn->error;} 
aktuelle fehlermeldung

Code:
New record created successfullyError: Select `id` from `s_categories` where `description` = 'Lebensmittelbeutel aus Papier '
Error: INSERT INTO `s_categories_attributes` (`id`,`categoryID`,`attribute1`,`attribute2`,`attribute3`,`attribute4`,`attribute5`,`attribute6`) VALUES (NULL,'Select `id` from `s_categories` where `description` = 'Lebensmittelbeutel aus Papier '','','','','','','' )
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Lebensmittelbeutel aus Papier '','','','','','','' )' at line 1You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Lebensmittelbeutel aus Papier '','','','','','','' )' at line 1New record created successfullyError: Select `id` from `s_categories` where `description` = 'Servietten "ROYAL Collection"'
Error: INSERT INTO `s_categories_attributes` (`id`,`categoryID`,`attribute1`,`attribute2`,`attribute3`,`attribute4`,`attribute5`,`attribute6`) VALUES (NULL,'Select `id` from `s_categories` where `description` = 'Servietten "ROYAL Collection"'','','','','','','' )
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Servietten "ROYAL Collection"'','','','','','','' )' at line 1You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Servietten "ROYAL Collection"'','','','','','','' )' at line 1New record created successfullyError: Select `id` from `s_categories` where `description` = 'Servietten "ROYAL Collection"'
Error: INSERT INTO `s_categories_attributes` (`id`,`categoryID`,`attribute1`,`attribute2`,`attribute3`,`attribute4`,`attribute5`,`attribute6`) VALUES (NULL,'Select `id` from `s_categories` where `description` = 'Servietten "ROYAL Collection"'','','','','','','' )
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Servietten "ROYAL Collection"'','','','','','','' )' at line 1You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Servietten "ROYAL Collection"'','','','','','','' )' at line 13.990295 Sekunden
Mit Zitat antworten