We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10405
    • 288 Posts
    I have a very odd issue with a snippet not showing at all in a resource- either with the [[ or the [! tags. It’s basically the presentation code for a Flash SWF plus a mySQL query to a db which has been set up and is working.

    It looks as if it just isn’t reading the snippet properly, because I can add errors into the mySQL query or anywhere else and it doesn’t do anything. Looking at the outputted page source code, there’s absolutely no ouput from the snippet whatsoever except an echo statement that I put in.

    Any ideas? (here’s the code)

    <?php
    include ('manager/advertising/inc/dbconnect.php');
      
    // Build SQL Query  
    $query = "SELECT * FROM home ORDER BY rand() LIMIT 1"; // specify the table and field names for the SQL query
     $numresults=mysql_query($query);
     $numrows=mysql_num_rows($numresults);
    // get results
      $result = mysql_query($query) or die("Couldn't execute query");
    // display the results returned
    while ($row= mysql_fetch_array($result)) {
      $title = $row["url"];
    echo $title;
    }
    
    echo '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="120" height="285" id="FlashID2" title="Radisson Hotels">
      <param name="movie" value=" ' . $title . '/>
      <param name="quality" value="high" />
      <param name="wmode" value="opaque" />
      <param name="swfversion" value="7.0.70.0" />
      <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
      <param name="expressinstall" value="scripts/expressInstall.swf" />
      <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="/1.swf" width="120" height="285">
        <!--<![endif]-->
        <param name="quality" value="high" />
        <param name="wmode" value="opaque" />
        <param name="swfversion" value="7.0.70.0" />
        <param name="expressinstall" value="scripts/expressInstall.swf" />
        <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
        <div>
          <h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
          <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
        </div>
        <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>
    <script type="text/javascript">
    <!--
    swfobject.registerObject("FlashID2");
    //-->
    </script>';
    ?>
    


    I should also point out that it does show the path when I echo the $title variable in the code (see above).
      • 26931
      • 2,314 Posts
      maybe change
      include ('manager/advertising/inc/dbconnect.php');

      to
      include_once($modx->config['base_path'].'manager/advertising/inc/dbconnect.php');

      -> http://wiki.modxcms.com/index.php/Creating_Snippets
        • 20413
        • 2,877 Posts
        and replace the echo’s with return’s
          @hawproductions | http://mrhaw.com/

          Infograph: MODX Advanced Install in 7 steps:
          http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

          Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
          http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
          • 10405
          • 288 Posts
          Tried the different include statement at the top but same result. Dkitto with using return instead of echo...

          Interestingly the pathname that I’m echoing is displaying ok (i.e it’s showing a randome one of four possible SWF files in the path, wich is correct).

          It just isn’t displaying the actual SWF file...
            • 10405
            • 288 Posts
            Weird- now got it working in FF but not IE8...

            So looks as if the code’s ok now.
              • 26931
              • 2,314 Posts
              @mrhaw: why should echo be replaced with return ? to end the loop?
                • 10405
                • 288 Posts
                Anyone have any idea why it would work in FF but not in IE? (or Safari, apparently)

                This is the current code (works fine in FF)

                <?php
                include ('manager/advertising/inc/dbconnect.php');
                  
                // Build SQL Query  
                $query = "SELECT * FROM home ORDER BY rand() LIMIT 1"; // specify the table and field names for the SQL query
                 $numresults=mysql_query($query);
                 $numrows=mysql_num_rows($numresults);
                // get results
                  $result = mysql_query($query) or die("Couldn't execute query");
                // display the results returned
                while ($row= mysql_fetch_array($result)) {
                  $title = $row["url"];
                }
                
                
                echo'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="120" height="285" id="FlashID8" title="">
                  <param name="movie" value="'.$title.'/>
                  <param name="quality" value="high" />
                  <param name="wmode" value="opaque" />
                  <param name="swfversion" value="7.0.70.0" />
                  <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
                  <param name="expressinstall" value="manager/advertising/scripts/expressInstall.swf" />
                  <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
                  <!--[if !IE]>-->
                  <object type="application/x-shockwave-flash" data="'.$title.'" width="120" height="285">
                    <!--<![endif]-->
                    <param name="quality" value="high" />
                    <param name="wmode" value="opaque" />
                    <param name="swfversion" value="7.0.70.0" />
                    <param name="expressinstall" value="manager/advertising/scripts/expressInstall.swf" />
                    <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
                    <div>
                      <h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
                      <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
                    </div>
                    <!--[if !IE]>-->
                  </object>
                  <!--<![endif]-->
                </object>
                <script type="text/javascript">
                <!--
                swfobject.registerObject("FlashID8");
                //-->
                </script>';
                ?>
                
                  • 20413
                  • 2,877 Posts
                  @Sharkbait - I never get echo to do much inside MODx...
                  Maybe its my code...

                  This is what I would try
                  Either use print instead of echo OR assign the echo
                  to a variable and print/return the variable!
                    @hawproductions | http://mrhaw.com/

                    Infograph: MODX Advanced Install in 7 steps:
                    http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                    Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                    http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                    • 3749
                    • 24,544 Posts
                    Quote from: mrhaw at Oct 02, 2009, 12:47 AM

                    @Sharkbait - I never get echo to do much inside MODx...
                    Maybe its my code...

                    This is what I would try
                    Either use print instead of echo OR assign the echo
                    to a variable and print/return the variable!


                    The conventional method in MODx is:

                    $output = 'Something';
                    
                    // some code
                    
                    $output .= 'Something Else';
                    
                    // more code
                    
                    return $output;


                    I don’t think that will help the OP, though. I suspect that the issue is the code that’s being hidden from IE with the conditional comments.
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                      • 20413
                      • 2,877 Posts
                      Sweet -> http://www.bobsguides.com/modx-snippets.html
                      BobRay with 2 hot chicks -> kiss grin kiss
                        @hawproductions | http://mrhaw.com/

                        Infograph: MODX Advanced Install in 7 steps:
                        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower