We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7606
    • 39 Posts
    J’ai récupéré ce code qui affiche (suivant un document html que je n’ai pas affiché ici) un formulaire pour faire un upload d’un fichier word.

    Lorsque je le lance dans un fichier php seul, pas de problème, mais quand je le mets dans un snippet pour modx, dès que je fais "sauvegarder", ça me mets plein d’erreur en rouge (dans modx directement)... je peux faire un screenshot si vous voulez.

    Où est-ce que ça coince pour Modx ?

    Merci d’avance


    <?php

    if(isset($_FILES[’photo’]))
    {
    // params
    unset($erreur);
    $extensions_ok = array(’doc’, ’docx’);
    $taille_max = 100000;
    $dest_dossier = ’frecu/’;
    // vérifications
    if( !in_array( substr(strrchr($_FILES[’photo’][’name’], ’.’), 1), $extensions_ok ) )
    {
    $erreur = ’Veuillez sélectionner un fichier de type doc ou docx !’;
    }
    elseif( file_exists($_FILES[’photo’][’tmp_name’])
    and filesize($_FILES[’photo’][’tmp_name’]) > $taille_max)
    {
    $erreur = ’Votre fichier doit faire moins de 500Ko !’;
    }
    // copie du fichier
    if(!isset($erreur))
    {
    $dest_fichier = basename($_FILES[’photo’][’name’]);
    // formatage nom fichier
    // enlever les accents
    $dest_fichier = strtr($dest_fichier, ’ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ’, ’AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy’);
    // remplacer les caracteres autres que lettres, chiffres et point par _
    $dest_fichier = preg_replace(’/([^.a-z0-1]+)/i’, ’_’, $dest_fichier);
    // copie du fichier
    move_uploaded_file($_FILES[’photo’][’tmp_name’], $dest_dossier . $dest_fichier);
    }
    }

    ?>
      • 5811
      • 1,717 Posts
      Sans le détail des erreurs, difficile à dire. Donc oui un copy/paste des erreurs serait utile
        • 7606
        • 39 Posts
        Voila le GRAND message d’erreur que ça me fait !!!

        impossible à comprendre tout ce charabia... en regardant un peu, on dirait qu’il essaie d’arriver dans une bdd qui n’existe pas... mais je peux bien sûr me tromper (en plus, j’ai plein de //// qui sont dans le message d’erreur).

        « MODx Parse Error »
        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - Incorrect string value: ’\xC3\x80\xC3\x81\xC3\x82...’ for column ’snippet’ at row 1 »
        SQL: INSERT INTO `modx`.`modx_site_snippets` (name, description, snippet, moduleguid, locked, properties, category) VALUES(’test’, ’’, ’\r\n\r\nif(isset($_FILES[\’photo\’]))\r\n{\r\n // params\r\n unset($erreur);\r\n $extensions_ok = array(\’doc\’, \’docx\’);\r\n $taille_max = 100000;\r\n $dest_dossier = \’frecu/\’;\r\n // vérifications\r\n if( !in_array( substr(strrchr($_FILES[\’photo\’][\’name\’], \’.\’), 1), $extensions_ok ) )\r\n {\r\n $erreur = \’Veuillez sélectionner un fichier de type doc ou docx !\’;\r\n }\r\n elseif( file_exists($_FILES[\’photo\’][\’tmp_name\’])\r\n and filesize($_FILES[\’photo\’][\’tmp_name\’]) > $taille_max)\r\n {\r\n $erreur = \’Votre fichier doit faire moins de 500Ko !\’;\r\n }\r\n // copie du fichier\r\n if(!isset($erreur))\r\n {\r\n $dest_fichier = basename($_FILES[\’photo\’][\’name\’]);\r\n // formatage nom fichier\r\n // enlever les accents\r\n $dest_fichier = strtr($dest_fichier, \’ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ\’, \’AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy\’);\r\n // remplacer les caracteres autres que lettres, chiffres et point par _\r\n $dest_fichier = preg_replace(\’/([^.a-z0-1]+)/i\’, \’_\’, $dest_fichier);\r\n // copie du fichier\r\n move_uploaded_file($_FILES[\’photo\’][\’tmp_name\’], $dest_dossier . $dest_fichier);\r\n }\r\n}\r\n\r\n’, ’ ’, ’0’,’’, ’0’);
        [Copy SQL to ClipBoard]

        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313191.9135 s
        Total: 1259313191.9155 s
        « MODx Parse Error »
        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - Incorrect string value: ’\xC3\x80\xC3\x81\xC3\x82...’ for column ’description’ at row 1 »
        SQL: INSERT INTO `modx`.`modx_event_log` (eventid,type,createdon,source,description,user) VALUES(0,3,1259313191,’Parser’,’\n \n \n \n \n
        « MODx Parse Error »
        \n \n \n
        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - Incorrect string value: \’\\xC3\\x80\\xC3\\x81\\xC3\\x82...\’ for column \’snippet\’ at row 1 »
        SQL: INSERT INTO `modx`.`modx_site_snippets` (name, description, snippet, moduleguid, locked, properties, category) VALUES(\’test\’, \’\’, \’\\r\\n\\r\\nif(isset($_FILES[\\\’photo\\\’]))\\r\\n{\\r\\n // params\\r\\n unset($erreur);\\r\\n $extensions_ok = array(\\\’doc\\\’, \\\’docx\\\’);\\r\\n $taille_max = 100000;\\r\\n $dest_dossier = \\\’frecu/\\\’;\\r\\n // vérifications\\r\\n if( !in_array( substr(strrchr($_FILES[\\\’photo\\\’][\\\’name\\\’], \\\’.\\\’), 1), $extensions_ok ) )\\r\\n {\\r\\n $erreur = \\\’Veuillez sélectionner un fichier de type doc ou docx !\\\’;\\r\\n }\\r\\n elseif( file_exists($_FILES[\\\’photo\\\’][\\\’tmp_name\\\’])\\r\\n and filesize($_FILES[\\\’photo\\\’][\\\’tmp_name\\\’]) > $taille_max)\\r\\n {\\r\\n $erreur = \\\’Votre fichier doit faire moins de 500Ko !\\\’;\\r\\n }\\r\\n // copie du fichier\\r\\n if(!isset($erreur))\\r\\n {\\r\\n $dest_fichier = basename($_FILES[\\\’photo\\\’][\\\’name\\\’]);\\r\\n // formatage nom fichier\\r\\n // enlever les accents\\r\\n $dest_fichier = strtr($dest_fichier, \\\’ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ\\\’, \\\’AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy\\\’);\\r\\n // remplacer les caracteres autres que lettres, chiffres et point par _\\r\\n $dest_fichier = preg_replace(\\\’/([^.a-z0-1]+)/i\\\’, \\\’_\\\’, $dest_fichier);\\r\\n // copie du fichier\\r\\n move_uploaded_file($_FILES[\\\’photo\\\’][\\\’tmp_name\\\’], $dest_dossier . $dest_fichier);\\r\\n }\\r\\n}\\r\\n\\r\\n\’, \’ \’, \’0\’,\’\’, \’0\’);\n
        [Copy SQL to ClipBoard]

        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313191.9135 s
        Total: 1259313191.9155 s
        ’,’1’)
        [Copy SQL to ClipBoard]

        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313191.9263 s
        Total: 1259313191.9283 s
        « MODx Parse Error »
        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - Incorrect string value: ’\xC3\x80\xC3\x81\xC3\x82...’ for column ’description’ at row 1 »
        SQL: INSERT INTO `modx`.`modx_event_log` (eventid,type,createdon,source,description,user) VALUES(0,3,1259313191,’Parser’,’\n \n \n \n \n
        « MODx Parse Error »
        \n \n \n
        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - Incorrect string value: \’\\xC3\\x80\\xC3\\x81\\xC3\\x82...\’ for column \’description\’ at row 1 »
        SQL: INSERT INTO `modx`.`modx_event_log` (eventid,type,createdon,source,description,user) VALUES(0,3,1259313191,\’Parser\’,\’\\n \\n \\n \\n \\n
        « MODx Parse Error »
        \\n \\n \\n
        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - Incorrect string value: \\\’\\\\xC3\\\\x80\\\\xC3\\\\x81\\\\xC3\\\\x82...\\\’ for column \\\’snippet\\\’ at row 1 »
        [Copy SQL to ClipBoard]

        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313191.9135 s
        Total: 1259313191.9155 s
        \’,\’1\’)\n
        [Copy SQL to ClipBoard]

        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313191.9263 s
        Total: 1259313191.9283 s
        ’,’1’)
        [Copy SQL to ClipBoard]

        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313191.9271 s
        Total: 1259313191.9290 s
        « MODx Parse Error »
        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - Incorrect string value: ’\xC3\x80\xC3\x81\xC3\x82...’ for column ’description’ at row 1 »
        SQL: INSERT INTO `modx`.`modx_event_log` (eventid,type,createdon,source,description,user) VALUES(0,3,1259313191,’Parser’,’\n \n \n \n \n
        « MODx Parse Error »
        \n \n \n
        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - Incorrect string value: \’\\xC3\\x80\\xC3\\x81\\xC3\\x82...\’ for column \’description\’ at row 1 »
        SQL: INSERT INTO `modx`.`modx_event_log` (eventid,type,createdon,source,description,user) VALUES(0,3,1259313191,\’Parser\’,\’\\n \\n \\n \\n \\n
        « MODx Parse Error »
        \\n \\n \\n
        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - Incorrect string value: \\\’\\\\xC3\\\\x80\\\\xC3\\\\x81\\\\xC3\\\\x82...\\\’ for column \\\’description\\\’ at row 1 »
        SQL: INSERT INTO `modx`.`modx_event_log` (eventid,type,createdon,source,description,user) VALUES(0,3,1259313191,\\\’Parser\\\’,\\\’\\\\n \\\\n \\\\n \\\\n \\\\n
        « MODx Parse Error »
        \\\\n \\\\n \\\\n
        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - Incorrect string value: \\\\\\\’\\\\\\\\xC3\\\\\\\\x80\\\\\\\\xC3\\\\\\\\x81\\\\\\\\xC3\\\\\\\\x82...\\\\\\\’ for column \\\\\\\’snippet\\\\\\\’ at row 1 »
        SQL: INSERT INTO `modx`.`modx_site_snippets` (name, description, snippet, moduleguid, locked, properties, category)
        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313191.9135 s
        Total: 1259313191.9155 s
        \\\’,\\\’1\\\’)\\n
        [Copy SQL to ClipBoard]

        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313191.9263 s
        Total: 1259313191.9283 s
        \’,\’1\’)\n
        [Copy SQL to ClipBoard]

        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313191.9271 s
        Total: 1259313191.9290 s
        ’,’1’)
        [Copy SQL to ClipBoard]

        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313191.9278 s
        Total: 1259313191.9298 s
        « MODx Parse Error »
        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - Incorrect string value: ’\xC3\x80\xC3\x81\xC3\x82...’ for column ’description’ at row 1 »
        SQL: INSERT INTO `modx`.`modx_event_log` (eventid,type,createdon,source,description,user) VALUES(0,3,1259313191,’Parser’,’\n \n \n \n \n
        « MODx Parse Error »
        \n \n \n
        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - Incorrect string value: \’\\xC3\\x80\\xC3\\x81\\xC3\\x82...\’ for column \’description\’ at row 1 »
        SQL: INSERT INTO `modx`.`modx_event_log` (eventid,type,createdon,source,description,user) VALUES(0,3,1259313191,\’Parser\’,\’\\n \\n \\n \\n \\n
        « MODx Parse Error »
        \\n \\n \\n
        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - Incorrect string value: \\\’\\\\xC3\\\\x80\\\\xC3\\\\x81\\\\xC3\\\\x82...\\\’ for column \\\’description\\\’ at row 1 »
        SQL: INSERT INTO `modx`.`modx_event_log` (eventid,type,createdon,source,description,user) VALUES(0,3,1259313191,\\\’Parser\\\’,\\\’\\\\n \\\\n \\\\n \\\\n \\\\n
        « MODx Parse Error »
        \\\\n \\\\n \\\\n
        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - Incorrect string value: \\\\\\\’\\\\\\\\xC3\\\\\\\\x80\\\\\\\\xC3\\\\\\\\x81\\\\\\\\xC3\\\\\\\\x82...\\\\\\\’ for column \\\\\\\’description\\\\\\\’ at row 1 »
        SQL: INSERT INTO `modx`.`modx_event_log` (eventid,type,createdon,source,description,user) VALUES(0,3,1259313191,\\\\\\\’Parser\\\\\\\’,\\\\\\\’\\\\\\\\n \\\\\\\\n \\\\\\\\n \\\\\\\\n \\\\\\\\n
        « MODx Parse Error »
        \\\\\\\\n \\\\\\\\n \\\\\\\\n
        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - Incorrect string value: \\\\\\\\\\\\\\\’\\\\\\\\\\\\\\\\xC3\\\\\\\\\\\\\\\\x80\\\\\\\\\\\\\\\\xC3\\\\\\\\\\\\\\\\x81\\\\\\\\\\\\\\\\xC3\\\\\\\\\\\\\\\\x82...\\\\\\\\\\\\\\\’ for column \\\\\\\\\\\\\\\’snippet\\\\\\\\\\\\\\\’ at row 1 »

        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313191.9135 s
        Total: 1259313191.9155 s
        \\\\\\\’,\\\\\\\’1\\\\\\\’)\\\\n
        [Copy SQL to ClipBoard]

        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313191.9263 s
        Total: 1259313191.9283 s
        \\\’,\\\’1\\\’)\\n
        [Copy SQL to ClipBoard]

        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313191.9271 s
        Total: 1259313191.9290 s
        \’,\’1\’)\n
        [Copy SQL to ClipBoard]

        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313191.9278 s
        Total: 1259313191.9298 s
        ’,’1’)
        [Copy SQL to ClipBoard]

        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313191.9289 s
        Total: 1259313191.9309 s
        « MODx Parse Error »
        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - Incorrect string value: ’\xC3\x80\xC3\x81\xC3\x82...’ for column ’description’ at row 1 »
        SQL: INSERT INTO `modx`.`modx_event_log` (eventid,type,createdon,source,description,user) VALUES(0,3,1259313191,’Parser’,’\n \n \n \n \n
        « MODx Parse Error »
        \n \n \n
        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - Incorrect string value: \’\\xC3\\x80\\xC3\\x81\\xC3\\x82...\’ for column \’description\’ at row 1 »
        SQL: INSERT INTO `modx`.`modx_event_log` (eventid,type,createdon,source,description,user) VALUES(0,3,1259313191,\’Parser\’,\’\\n \\n \\n \\n \\n
        « MODx Parse Error »
        \\n \\n \\n
        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - Incorrect string value: \\\’\\\\xC3\\\\x80\\\\xC3\\\\x81\\\\xC3\\\\x82...\\\’ for column \\\’description\\\’ at row 1 »
        SQL: INSERT INTO `modx`.`modx_event_log` (eventid,type,createdon,source,description,user) VALUES(0,3,1259313191,\\\’Parser\\\’,\\\’\\\\n \\\\n \\\\n \\\\n \\\\n
        « MODx Parse Error »
        \\\\n \\\\n \\\\n
        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - Incorrect string value: \\\\\\\’\\\\\\\\xC3\\\\\\\\x80\\\\\\\\xC3\\\\\\\\x81\\\\\\\\xC3\\\\\\\\x82...\\\\\\\’ for column \\\\\\\’description\\\\\\\’ at row 1 »
        SQL: INSERT INTO `modx`.`modx_event_log` (eventid,type,createdon,source,description,user) VALUES(0,3,1259313191,\\\\\\\’Parser\\\\\\\’,\\\\\\\’\\\\\\\\n \\\\\\\\n \\\\\\\\n \\\\\\\\n \\\\\\\\n
        « MODx Parse Error »
        \\\\\\\\n \\\\\\\\n \\\\\\\\n
        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - Incorrect string value: \\\\\\\\\\\\\\\’\\\\\\\\\\\\\\\\xC3\\\\\\\\\\\\\\\\x80\\\\\\\\\\\\\\\\xC3\\\\\\\\\\\\\\\\x81\\\\\\\\\\\\\\\\xC3\\\\\\\\\\\\\\\\x82...\\\\\\\\\\\\\\\’ for column
        [Copy SQL to ClipBoard]

        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313191.9308 s
        Total: 1259313191.9328 s
        \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’,\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’1\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’)\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n
        [Copy SQL to ClipBoard]

        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313191.9331 s
        Total: 1259313191.9351 s
        \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’,\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’1\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’)\\\\\\\\\\\\\\\\n
        [Copy SQL to ClipBoard]

        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313191.9366 s
        Total: 1259313191.9386 s
        \\\\\\\\\\\\\\\’,\\\\\\\\\\\\\\\’1\\\\\\\\\\\\\\\’)\\\\\\\\n
        [Copy SQL to ClipBoard]

        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313191.9408 s
        Total: 1259313191.9428 s
        \\\\\\\’,\\\\\\\’1\\\\\\\’)\\\\n
        [Copy SQL to ClipBoard]

        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313192.0304 s
        Total: 1259313192.0324 s
        \\\’,\\\’1\\\’)\\n
        [Copy SQL to ClipBoard]

        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313192.3034 s
        Total: 1259313192.3054 s
        \’,\’1\’)\n
        [Copy SQL to ClipBoard]

        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313192.5689 s
        Total: 1259313192.5709 s
        ’,’1’)
        [Copy SQL to ClipBoard]

        Parser timing
        MySQL: 0.0020 s (1 Requests)
        PHP: 1259313193.3952 s
        Total: 1259313193.3972 s
          • 5811
          • 1,717 Posts
          Bon tu peux virer le message laugh

          L’insert du code de ton snippet dans la table `modx`.`modx_site_snippets` plante. Même chose pour les ordres SQL suivants.
          Pour infos, j’ai inséré le même code sans pbs. Est ce que tu arrives à faire autre chose ?
            • 5811
            • 1,717 Posts
            Tu lui a donné quel nom à ton snippet ?
            Incorrect string value: '\xC3\x80\xC3\x81\xC3\x82...' for column 'snippet' at row 1 
              • 7606
              • 39 Posts
              C’était mon premier snippet que j’ai crée.

              Avez-vous un exemple que je puisse faire un copier-coller et tester directement ?

              J’ai la version 1.0.2 de modx (en gris).

              J’ai donné le nom "test", tout simplement à mon snippet.

              que faire ? changer de version ? je vais tout perdre alors huh
                • 5811
                • 1,717 Posts
                Non , tu n’as pas à changer de version. Par contre je trouve ces messages trés surprenant. Es tu sûr de ton installation ? As tu pu créer un document sans pbs ?
                  • 7606
                  • 39 Posts
                  oui, sans aucuns problèmes...

                  je suis easyphp et de temps en temps, je teste "online" et mon site est bien visible sans aucun autre problème que celui-là.

                  Ze gros problème, c’est que c’est la partie centrale de mon site internet (récupérer des fichiers word) et donc, tant que ce n’est pas résolu, je suis "en attente" de pouvoir continuer.

                  L’installation s’est passée correctement, sans aucuns disfonctionnement, que des "ok" vert,...
                    • 5811
                    • 1,717 Posts
                    Quel est encodage de ta base mySql ? utf-8 ou latin 1 ?

                    Pour infos : http://www.forum.moteurprog.com/perl/forum-msg-32127-1.htm
                      • 7606
                      • 39 Posts
                      Francais-utf8

                      Unicode (UTF-8) utf-8

                      Est-ce cela que tu voulais dire ?