SELFPHP: Version 5.8.2 Befehlsreferenz - Tutorial – Kochbuch – Forum für PHP Einsteiger und professionelle Entwickler

SELFPHP


Professional CronJob-Service

Suche



CronJob-Service    
bei SELFPHP mit ...



 + minütlichen Aufrufen
 + eigenem Crontab Eintrag
 + unbegrenzten CronJobs
 + Statistiken
 + Beispielaufrufen
 + Control-Bereich

Führen Sie mit den CronJobs von SELFPHP zeitgesteuert Programme auf Ihrem Server aus. Weitere Infos



:: Buchempfehlung ::

Handbuch der Java-Programmierung

Handbuch der Java-Programmierung zur Buchempfehlung
 

:: Anbieterverzeichnis ::

Globale Branchen

Informieren Sie sich über ausgewählte Unternehmen im Anbieterverzeichnis von SELFPHP  

 

:: Newsletter ::

Abonnieren Sie hier den kostenlosen SELFPHP Newsletter!

Vorname: 
Name:
E-Mail:
 
 

Zurück   PHP Forum > SELFPHP > MySQLi/PDO/(MySQL)

MySQLi/PDO/(MySQL) Anfänger, Fortgeschrittene oder Experten können hier Fragen und Probleme rund um MySQLi/PDO/(MySQL) diskutieren

Antwort
 
Themen-Optionen Ansicht
  #1  
Alt 15.03.2016, 16:43:00
Bengelbaer Bengelbaer ist offline
Anfänger
 
Registriert seit: Mar 2016
Alter: 44
Beiträge: 2
Datenübergabe Array -> Datenbank

Hy,

ich bin Michael und Baujahr 1979. Ich arbeite normalerweise im Vertrieb von Werkzeugen, und programmiere nur hobbymäßig etwas.

Hierzu setze ich mir immer Ziele welche ich erreichen möchte.

Aktuell versuche ich Kategorien aus einem Array in eine Datenbank zu schreiben.

Aber irgendwie haut was nicht hin, und ich bin grad etwas betriebsblind.

Daher würde es mich freuen wenn einer mal kurz drüber schauen könnte.

PHP-Code:
$conn = new mysqli($zDbHost$zDbUser$zDbPass$zDbDb);

                    
/* check connection */
if ($conn->connect_error) {
    die(
"Connection failed: " $mysqli->connect_error);

//////////////////////////////////////////Schleife für Kategorienerstellung////////////////////////////////////
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++;    
}; 
und hier die Ausgabe

Code:
Error: 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 ('', '3', '|3|', 'Lebensmittelbeutel aus Papier ', NULL, '0', '0', '0', '2016-03-15 15:33:13', '2016-03-15 15:33:13', NULL, '', '', '', 'article_listing_4col.tpl', '0', '1', '0', '1', '', '0', '0', NULL, 'basic', '', NULL )
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 'left, right, level, added, ' at line 6Error: 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 1Error: 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 ('', '3', '|3|', 'Servietten "ROYAL Collection"', NULL, '0', '0', '0', '2016-03-15 15:33:13', '2016-03-15 15:33:13', NULL, '', '', '', 'article_listing_4col.tpl', '0', '1', '0', '1', '', '0', '0', NULL, 'basic', '', NULL )
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 'left, right, level, added, ' at line 6Error: 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 1Error: 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 ('', '3', '|3|', 'Servietten "ROYAL Collection"', NULL, '0', '0', '0', '2016-03-15 15:33:13', '2016-03-15 15:33:13', NULL, '', '', '', 'article_listing_4col.tpl', '0', '1', '0', '1', '', '0', '0', NULL, 'basic', '', NULL )
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 'left, right, level, added, ' at line 6Error: 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 15.997079 Sekunden

vermutlich ist es ein einfacher Fehler.

Vielen Dank schon mal.
Mit Zitat antworten
  #2  
Alt 15.03.2016, 17: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
  #3  
Alt 15.03.2016, 17:20:29
Benutzerbild von vt1816
vt1816 vt1816 ist offline
Administrator
 
Registriert seit: Jul 2004
Beiträge: 3.707
AW: Datenübergabe Array -> Datenbank

Hallo und willkommen hier im Forum.


Beschäftige Dich mit der Problematik der reservierten Wörter in MySQL, setze die Feldnamen in `` (Backticks) und maskiere die Hochkomma in der Artikelbeschreibung u.a.
Weitere Ausführungen findest Du auch hier (Typische Fehlerquellen im SQL).

PS: Für eine bessere Lesbarkeit der Fehlermeldung arbeite bitte mit Zeilenumbrüchen und trenne Fehlermeldungen.
__________________
Gruss vt1816
Erwarte nicht, dass sich jemand mehr Mühe mit der Antwort gibt als Du Dir mit der Frage.
. . . . . Feedback wäre wünschenswert

Ich werde keinen privaten 1:1 Support leisten, außer ich biete ihn ausdrücklich an.
Ansosnten gilt: Hilfe ausserhalb dieses Thread (PN, WhatsApp, Skype, Mail, ICQ, etc...) nur per Barzahlung oder Vorauskasse!

Wenn man sich selbst als "Noob" bezeichnet, sollte man die Finger davon lassen.
Wenn man gewillt ist daran etwas zu ändern, lernt man Grundlagen!
Mit Zitat antworten
Antwort


Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
 
Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind aus.
[IMG] Code ist aus.
HTML-Code ist aus.

Gehe zu

Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
Anfängerproblem mit Formular-Ausgabe robertdeniro PHP Grundlagen 0 13.10.2006 12:11:50
anfängerproblem bei einem code pascalplus PHP Grundlagen 3 21.10.2004 15:40:40
frage zu explode wahrscheinlich anfängerproblem saidbuchari PHP Grundlagen 3 04.11.2003 09:16:01
Anfängerproblem (bzgl. Array) Carsten25 PHP für Fortgeschrittene und Experten 2 27.01.2003 09:18:12
Emailversand (Anfängerproblem !) Albtraum PHP für Fortgeschrittene und Experten 20 31.08.2002 10:57:45


Alle Zeitangaben in WEZ +2. Es ist jetzt 18:25:29 Uhr.


Powered by vBulletin® Version 3.8.3 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.


© 2001-2024 E-Mail SELFPHP OHG, info@selfphp.deImpressumKontakt