Probleme module PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ORiGaMi
    New Member
    • Sep 2015
    • 17
    • 5.1.x

    Probleme module PHP

    Bonjour,
    je présente un site prochainement, bonjour à tous,
    tout d'abord je n'arrive pas a retrouver mon vieux compte d'il y a 12 ans
    enfin bref je suis inscrit.

    ma version de Vbulletin est 5.1.9 upgradé depuis 5.1.8

    Mon problème:
    on a crée la page PHP de barème des prix hormis le forum vB.

    ensuit de cela, la page PHP de barème est opérationnel, ils'agit bien de même code, voir sous:


    je l'ai donc inclus dans la page module php proposant par vBulletin voir sous:


    à partir de là elle ne s'affiche rien, tout vide car mon codeur PHP pense fortement que le code php se refuse de lancer à cause de vBulletin.

    quel est la modification code php pour exécuter le module php fourni par vb ?
    comment faire?
    sur ce je n'ai pas trouvé des infos partout avec la recherche google.

    svp aidez moi c'est une dernière ligne droite

    d'avance merci
    Last edited by ORiGaMi; Fri 25 Sep '15, 12:29am.
  • ORiGaMi
    New Member
    • Sep 2015
    • 17
    • 5.1.x

    #2
    bonjour,
    personne?

    up

    Comment

    • Lynne
      Former vBulletin Support
      • Oct 2004
      • 26255

      #3
      Can you paste your php code here in the PHP tags?

      Please don't PM or VM me for support - I only help out in the threads.
      vBulletin Manual & vBulletin 4.0 Code Documentation (API)
      Want help modifying your vbulletin forum? Head on over to vbulletin.org
      If I post CSS and you don't know where it goes, throw it into the additional.css template.

      W3Schools <- awesome site for html/css help

      Comment

      • Yves R.
        vBulletin QA
        • Nov 2003
        • 3855
        • 5.6.X

        #4
        Peux-tu mettre ici le code PHP qui doit afficher le contenu ?

        Le mieux pour ce genre de chose serait de passer par vbulletin.org pour les modifications.

        vBulletin QA - vBulletin Support French - Lead Project Tools developer

        Next release? Soon(tm)

        Comment

        • ORiGaMi
          New Member
          • Sep 2015
          • 17
          • 5.1.x

          #5
          Originally posted by Yves Rigaud
          Peux-tu mettre ici le code PHP qui doit afficher le contenu ?

          Le mieux pour ce genre de chose serait de passer par vbulletin.org pour les modifications.

          bonjour,
          enfin vous etes là, je vous en remercie :

          le code que j'ai collé, dans la page module html ou page php, en question :

          <?php
          require_once(../01-bareme/00/php/config.php');

          $rs_results = mysql_query("select * from figurine order by id") or die(mysql_error());
          ?>
          <p>En test</p>
          <p>N'oubliez pas de lire les régles sous onglet de barre de navigation</p>

          <table width="1102" height="79" border="1">
          <tr>
          <th width="42" style="width:20px;height:23px;" scope="col">N°</th>
          <th width="55" style="width:58px;" scope="col">-= Figurine =-</th>
          <th width="41" style="width:10px;" scope="col">boîte</th>
          <th width="81" style="width:10px;" scope="col">chevelure</th>
          <th width="45" style="width:10px;" scope="col">corps</th>
          <th width="57" style="width:10px;" scope="col">casque</th>
          <th width="67" style="width:10px;" scope="col">plastron</th>
          <th width="77" style="width:10px;" scope="col">épaulette</th>
          <th width="41" style="width:10px;" scope="col">brasL</th>
          <th width="41" style="width:10px;" scope="col">brasR</th>
          <th width="40" style="width:10px;" scope="col">main</th>
          <th width="67" style="width:10px;" scope="col">ceinture</th>
          <th width="45" style="width:10px;" scope="col">tibias</th>
          <th width="59" style="width:10px;" scope="col">mèche </th>
          <th width="36" style="width:10px;" scope="col">tête</th>
          <th width="50" style="width:10px;" scope="col">genou</th>
          <th width="48" style="width:10px;" scope="col">totem</th>
          <th width="98" style="width:10px;" scope="col">accessoire</th>
          </tr>
          <?php while ($rrows = mysql_fetch_array($rs_results)) {$i +=1;?>
          <tr>
          <td style="text-align: center" scope="col"><?php echo $rrows['id']; ?></td>
          <td style="text-align: center" scope="col"><?php echo $rrows['nom']; ?></td>
          <td style="text-align: center" scope="col"><?php echo $rrows['prix_boite']; ?> €</td>
          <td style="text-align: center" scope="col"><?php echo $rrows['prix_chevelure']; ?> €</td>
          <td style="text-align: center" scope="col"><?php echo $rrows['prix_corps']; ?> €</td>
          <td style="text-align: center" scope="col"><?php echo $rrows['prix_casque']; ?> €</td>
          <td style="text-align: center" scope="col"><?php echo $rrows['prix_plastron']; ?> €</td>
          <td style="text-align: center" scope="col"><?php echo $rrows['prix_epaulette']; ?> €</td>
          <td style="text-align: center" scope="col"><?php echo $rrows['prix_bras_g']; ?> €</td>
          <td style="text-align: center" scope="col"><?php echo $rrows['prix_bras_d']; ?> €</td>
          <td style="text-align: center" scope="col"><?php echo $rrows['prix_main']; ?> €</td>
          <td style="text-align: center" scope="col"><?php echo $rrows['prix_ceinture']; ?> €</td>
          <td style="text-align: center" scope="col"><?php echo $rrows['prix_tibias']; ?> €</td>
          <td style="text-align: center" scope="col"><?php echo $rrows['prix_meche']; ?> €</td>
          <td style="text-align: center" scope="col"><?php echo $rrows['prix_tete']; ?> €</td>
          <td style="text-align: center" scope="col"><?php echo $rrows['prix_genou']; ?> €</td>
          <td style="text-align: center" scope="col"><?php echo $rrows['prix_totem']; ?> €</td>
          <td style="text-align: center" scope="col"><?php echo $rrows['prix_accessoire']; ?> €</td>
          </tr>
          <?php } ?>
          </table>

          Comment

          • Wayne Luke
            vBulletin Technical Support Lead
            • Aug 2000
            • 73979

            #6
            Are you sure the database connection and query are working? There is no error checking in the code.
            Translations provided by Google.

            Wayne Luke
            The Rabid Badger - a vBulletin Cloud demonstration site.
            vBulletin 5 API

            Comment

            • Wayne Luke
              vBulletin Technical Support Lead
              • Aug 2000
              • 73979

              #7
              Okay... I've figured out your problems here. You cannot open and close PHP within a module. I've developed an example that hopefully your developer can modify for your needs.

              PHP Code:
              /* Database Connection */
              $products_server     =     'localhost';
              $products_database     =     'shop';
              $products_user         =     'root';
              $products_password     =     '';


              $products_conn = new mysqli($products_server$products_user$products_password$products_database);

              ob_start();
              if (
              $products_conn->connect_errno) {
                  echo 
              "Failed to connect to MySQL: (" $products_conn->connect_errno ") " $products_conn->connect_error;
              }

              // Pull the product information out of the database.
              if ($result $products_conn->query("SELECT * FROM products")) {
                  
              printf("<p>Total Products Found: %d</p>"$result->num_rows);

              }

              // Create array of Products
              while($row $result->fetch_array())
              {
              $products[] = $row;
              }

              // Output the table header
              printf ("<table>");
              printf ("<thead><tr><th>SKU</th><th>Title</th><th>Description</th><th>Price</th></tr></thead>");

              foreach(
              $products as $product)
              {
                  
              printf ("<tbody><tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr></tbody>"$product['productid'], $product['title'], $product['description'], $product['price']);
              }

              // Close Table
              printf ("</table>");
              ob_end_flush();

              // Database Connection
              $products_conn->close(); 
              It is a little different from your orginal code but should be easy to read. I am working on a more comprehensive tutorial as well.

              Click image for larger version

Name:	product output.png
Views:	101
Size:	24.6 KB
ID:	4330461
              Translations provided by Google.

              Wayne Luke
              The Rabid Badger - a vBulletin Cloud demonstration site.
              vBulletin 5 API

              Comment

              • ORiGaMi
                New Member
                • Sep 2015
                • 17
                • 5.1.x

                #8
                Originally posted by Wayne Luke
                Are you sure the database connection and query are working? There is no error checking in the code.
                Yes i am sur, see under : http://www.oscaromyth.com/forum/testbareme.php
                So the same code that i posted on php module of vbulletin does not work

                Originally posted by Wayne Luke
                Okay... I've figured out your problems here. You cannot open and close PHP within a module. I've developed an example that hopefully your developer can modify for your needs.

                [ATTACH=CONFIG]n4330461[/ATTACH]
                j'essayerai ce soir avec ton bout de code puis je te dis

                Comment

                • Yves R.
                  vBulletin QA
                  • Nov 2003
                  • 3855
                  • 5.6.X

                  #9
                  Le module PHP ne se code pas comme un fichier PHP ou HTML. Je vais effectuer quelques tests à partir de test données et revenir ici dans la journée avec des résultats.

                  vBulletin QA - vBulletin Support French - Lead Project Tools developer

                  Next release? Soon(tm)

                  Comment

                  • Yves R.
                    vBulletin QA
                    • Nov 2003
                    • 3855
                    • 5.6.X

                    #10
                    Voici en image le code fonctionnel:

                    Click image for larger version

Name:	Capture d’écran 2015-10-05 à 19.23.06.png
Views:	154
Size:	96.9 KB
ID:	4330582

                    Et le code basé sur le code de Wayne plus haut:

                    PHP Code:
                    //require_once(../01-bareme/00/php/config.php');

                    $products_server     =     'localhost';
                    $products_database     =     'shop';
                    $products_user         =     'root';
                    $products_password     =     '';

                    $products_conn = new mysqli($products_server$products_user$products_password$products_database);

                    ob_start();

                    if (
                    $products_conn->connect_errno)
                    {
                        echo 
                    "Failed to connect to MySQL: (" $products_conn->connect_errno ") " $products_conn->connect_error;
                    }

                    $rs_results $products_conn->query("SELECT * FROM figurine ORDER BY id");

                    while (
                    $row $rs_results->fetch_array())
                    {
                        
                    $data[] = $row;
                    }

                    printf("<p>En test</p>");
                    printf("<p>N'oubliez pas de lire les règles sous onglet de barre de navigation</p>");

                    printf("<table width="1102" height="79" border="1">");
                    printf("<tr>");
                    printf("<th width="42" style="width:20px;height:23px;" scope="col">N°</th>");
                    printf("<th width="55" style="width:58px;" scope="col">-= Figurine =-</th>");
                    printf("<th width="41" style="width:10px;" scope="col">boîte</th>");
                    printf("<th width="81" style="width:10px;" scope="col">chevelure</th>");
                    printf("<th width="45" style="width:10px;" scope="col">corps</th>");
                    printf("<th width="57" style="width:10px;" scope="col">casque</th>");
                    printf("<th width="67" style="width:10px;" scope="col">plastron</th>");
                    printf("<th width="77" style="width:10px;" scope="col">épaulette</th>");
                    printf("<th width="41" style="width:10px;" scope="col">brasL</th>");
                    printf("<th width="41" style="width:10px;" scope="col">brasR</th>");
                    printf("<th width="40" style="width:10px;" scope="col">main</th>");
                    printf("<th width="67" style="width:10px;" scope="col">ceinture</th>");
                    printf("<th width="45" style="width:10px;" scope="col">tibias</th>");
                    printf("<th width="59" style="width:10px;" scope="col">mèche </th>");
                    printf("<th width="36" style="width:10px;" scope="col">tête</th>");
                    printf("<th width="50" style="width:10px;" scope="col">genou</th>");
                    printf("<th width="48" style="width:10px;" scope="col">totem</th>");
                    printf("<th width="98" style="width:10px;" scope="col">accessoire</th>");
                    printf("</tr>");

                    foreach (
                    $data AS $rrows)
                    {
                        
                    printf("<tr>");
                        
                    printf("<td style="text-aligncenter" scope="col">%s</td>"$rrows['id']);
                        
                    printf("<td style="text-aligncenter" scope="col">%s</td>"$rrows['nom']);
                        
                    printf("<td style="text-aligncenter" scope="col">%s €</td>"$rrows['prix_boite']);
                        
                    printf("<td style="text-aligncenter" scope="col">%s €</td>"$rrows['prix_chevelure']);
                        
                    printf("<td style="text-aligncenter" scope="col">%s €</td>"$rrows['prix_corps']);
                        
                    printf("<td style="text-aligncenter" scope="col">%s €</td>"$rrows['prix_casque']);
                        
                    printf("<td style="text-aligncenter" scope="col">%s €</td>"$rrows['prix_plastron']);
                        
                    printf("<td style="text-aligncenter" scope="col">%s €</td>"$rrows['prix_epaulette']);
                        
                    printf("<td style="text-aligncenter" scope="col">%s €</td>"$rrows['prix_bras_g']);
                        
                    printf("<td style="text-aligncenter" scope="col">%s €</td>"$rrows['prix_bras_d']);
                        
                    printf("<td style="text-aligncenter" scope="col">%s €</td>"$rrows['prix_main']);
                        
                    printf("<td style="text-aligncenter" scope="col">%s €</td>"$rrows['prix_ceinture']);
                        
                    printf("<td style="text-aligncenter" scope="col">%s €</td>"$rrows['prix_tibias']);
                        
                    printf("<td style="text-aligncenter" scope="col">%s €</td>"$rrows['prix_meche']);
                        
                    printf("<td style="text-aligncenter" scope="col">%s €</td>"$rrows['prix_tete']);
                        
                    printf("<td style="text-aligncenter" scope="col">%s €</td>"$rrows['prix_genou']);
                        
                    printf("<td style="text-aligncenter" scope="col">%s €</td>"$rrows['prix_totem']);
                        
                    printf("<td style="text-aligncenter" scope="col">%s €</td>"$rrows['prix_accessoire']);
                        
                    printf("</tr>");
                    }

                    printf("</table>");

                    ob_end_flush();

                    $products_conn->close(); 
                    Dis-moi ce qu'il en est

                    vBulletin QA - vBulletin Support French - Lead Project Tools developer

                    Next release? Soon(tm)

                    Comment

                    • ORiGaMi
                      New Member
                      • Sep 2015
                      • 17
                      • 5.1.x

                      #11
                      Bonjour,
                      super ce que tu as fait,

                      j'ai bien mis ce que tu as codé, rien ne s'affiche dans la page, testé sur module html et module php :
                      1. l'erreur indique failed to connect to mysql, pourtant mes données accés msql n'ont pas d'erreur.
                      2. la page module html s'affiche nickel et la page module php ne s'affiche rien et pourtant le module php de chez toi fonctionne


                      je remet ce code modifié:

                      /* Database Connection */

                      $products_server = 'mon_serveur';
                      $products_database = 'ma_db';
                      $products_user = 'login';
                      $products_password = 'pass';

                      $products_conn = new mysqli($products_server, $products_user, $products_password, $products_database);

                      ob_start();

                      if ($products_conn->connect_errno)
                      {
                      echo "Failed to connect to MySQL: (" . $products_conn->connect_errno . ") " . $products_conn->connect_error;
                      }

                      $rs_results = $products_conn->query("SELECT * FROM figurine ORDER BY id");

                      while ($row = $rs_results->fetch_array())
                      {
                      $data[] = $row;
                      }

                      printf("<p>En test</p>");
                      printf("<p>N'oubliez pas de lire les règles sous onglet de barre de navigation</p>");

                      printf("<table width="1102" height="79" border="1">");
                      printf("<tr>");
                      printf("<th width="42" style="width:20px;height:23px;" scope="col">N°</th>");
                      printf("<th width="55" style="width:58px;" scope="col">-= Figurine =-</th>");
                      printf("<th width="41" style="width:10px;" scope="col">boîte</th>");
                      printf("<th width="81" style="width:10px;" scope="col">chevelure</th>");
                      printf("<th width="45" style="width:10px;" scope="col">corps</th>");
                      printf("<th width="57" style="width:10px;" scope="col">casque</th>");
                      printf("<th width="67" style="width:10px;" scope="col">plastron</th>");
                      printf("<th width="77" style="width:10px;" scope="col">épaulette</th>");
                      printf("<th width="41" style="width:10px;" scope="col">brasL</th>");
                      printf("<th width="41" style="width:10px;" scope="col">brasR</th>");
                      printf("<th width="40" style="width:10px;" scope="col">main</th>");
                      printf("<th width="67" style="width:10px;" scope="col">ceinture</th>");
                      printf("<th width="45" style="width:10px;" scope="col">tibias</th>");
                      printf("<th width="59" style="width:10px;" scope="col">mèche </th>");
                      printf("<th width="36" style="width:10px;" scope="col">tête</th>");
                      printf("<th width="50" style="width:10px;" scope="col">genou</th>");
                      printf("<th width="48" style="width:10px;" scope="col">totem</th>");
                      printf("<th width="98" style="width:10px;" scope="col">accessoire</th>");
                      printf("</tr>");

                      foreach ($data AS $rrows)
                      {
                      printf("<tr>");
                      printf("<td style="text-align: center" scope="col">%s</td>", $rrows['id']);
                      printf("<td style="text-align: center" scope="col">%s</td>", $rrows['nom']);
                      printf("<td style="text-align: center" scope="col">%s €</td>", $rrows['prix_boite']);
                      printf("<td style="text-align: center" scope="col">%s €</td>", $rrows['prix_chevelure']);
                      printf("<td style="text-align: center" scope="col">%s €</td>", $rrows['prix_corps']);
                      printf("<td style="text-align: center" scope="col">%s €</td>", $rrows['prix_casque']);
                      printf("<td style="text-align: center" scope="col">%s €</td>", $rrows['prix_plastron']);
                      printf("<td style="text-align: center" scope="col">%s €</td>", $rrows['prix_epaulette']);
                      printf("<td style="text-align: center" scope="col">%s €</td>", $rrows['prix_bras_g']);
                      printf("<td style="text-align: center" scope="col">%s €</td>", $rrows['prix_bras_d']);
                      printf("<td style="text-align: center" scope="col">%s €</td>", $rrows['prix_main']);
                      printf("<td style="text-align: center" scope="col">%s €</td>", $rrows['prix_ceinture']);
                      printf("<td style="text-align: center" scope="col">%s €</td>", $rrows['prix_tibias']);
                      printf("<td style="text-align: center" scope="col">%s €</td>", $rrows['prix_meche']);
                      printf("<td style="text-align: center" scope="col">%s €</td>", $rrows['prix_tete']);
                      printf("<td style="text-align: center" scope="col">%s €</td>", $rrows['prix_genou']);
                      printf("<td style="text-align: center" scope="col">%s €</td>", $rrows['prix_totem']);
                      printf("<td style="text-align: center" scope="col">%s €</td>", $rrows['prix_accessoire']);
                      printf("</tr>");
                      }

                      printf("</table>");

                      ob_end_flush();

                      $products_conn->close();
                      Last edited by ORiGaMi; Tue 6 Oct '15, 1:02am.

                      Comment

                      • Wayne Luke
                        vBulletin Technical Support Lead
                        • Aug 2000
                        • 73979

                        #12
                        For the database connection, make sure that your PHP has the mysqli libraries installed. This is the preferred method since mysql is deprecated. Do not use the single quote in your username, password or database name either. It looks like something it breaking the sequence rather than an actual error. Unfortuantely the PHP Module doesn't bubble PHP errors up or seem to catch exceptions.

                        Lines like this are broken:
                        printf("<th width="42" style="width:20px;height:23px;" scope="col">N°</th>");

                        You either need to escape your double quotes ( " ) within the string with a \ or use single quotes ( ' ) for your HTML attributes. Easier just to use single quotes in my opinion. Syntax has to be perfect.

                        One way to test is to put your code in a standalone file and run it in a browser or from the PHP command line and note the errors.

                        I'll let Yves translate.
                        Last edited by Wayne Luke; Tue 6 Oct '15, 9:05am.
                        Translations provided by Google.

                        Wayne Luke
                        The Rabid Badger - a vBulletin Cloud demonstration site.
                        vBulletin 5 API

                        Comment

                        • Wayne Luke
                          vBulletin Technical Support Lead
                          • Aug 2000
                          • 73979

                          #13
                          Here is an image of the big problem. The yellow text is a string. The white text is PHP code. Lines 30 and 31 have been edited to show the two methods of dealing with quotes in a string.
                          Click image for larger version

Name:	snip_20151006100711.png
Views:	94
Size:	253.5 KB
ID:	4330637

                          Translations provided by Google.

                          Wayne Luke
                          The Rabid Badger - a vBulletin Cloud demonstration site.
                          vBulletin 5 API

                          Comment

                          • Yves R.
                            vBulletin QA
                            • Nov 2003
                            • 3855
                            • 5.6.X

                            #14
                            Ok, le problème est bien que les guillemets ne sont pas sous la forme ' \ " ' mais " dans le printf() (un \ devant un ").

                            Il semblerait que le code PHP (pouvant mettre en forme le code PHP comme je l'ai fait au-dessus) les ai retirés :/

                            Le code doit apparaître comme dans cette image:

                            Click image for larger version

Name:	Capture d’écran 2015-10-06 à 19.42.37.png
Views:	93
Size:	297.4 KB
ID:	4330641

                            vBulletin QA - vBulletin Support French - Lead Project Tools developer

                            Next release? Soon(tm)

                            Comment

                            • Yves R.
                              vBulletin QA
                              • Nov 2003
                              • 3855
                              • 5.6.X

                              #15
                              Originally posted by Wayne Luke
                              Lines like this are broken:
                              printf("<th width="42" style="width:20px;height:23px;" scope="col">N°</th>");
                              Just reported as a bug, still in 5.1.10: http://tracker.vbulletin.com/browse/VBV-15253

                              vBulletin QA - vBulletin Support French - Lead Project Tools developer

                              Next release? Soon(tm)

                              Comment

                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                              Working...