ok im try to solve a little problem with SMF 2.0 the package manager lists a description for each package on their servers.

Here is a description

Adds a new "Show debug information" setting Server Settings that enables/disables SMF's query debugging features. When enabled, SMF displays debug information at the bottom of each page which includes the following information:<br /><br /> Template files that were loaded Sub-template files that were loaded Language files that were loaded Style sheets that were loaded Number of files included (and which ones) Cache hits (and what they were) Queries used (including full details)<br />This information is very useful for debugging purposes. It's the same thing as adding the $db_show_debug=true line to your Settings.php file except that you don't have to keep manually editing your Settings.php to turn this feature on and off.<br /><br />Configuration<br /><br />The new setting appears on your Server Settings page: Admin -> Configuration -> Server Settings. Check to enable or uncheck to disable, then hit "Save." It's just that simple! <br /><br />Version history<br /><br />Version 1.0 (Oct. 22, 2008) original release.<br /><br />Donations<br /><br /> If you like my modification packages, please donate to support their continued development. Any amount will be greatly appreciated. Thank you!

as you can see it contains several " and some '

is there anway i can escape the quotes?
or would Magic Quotes need to be turned on?

    Don't use magic quotes ever. Put your strings in single quotes. If you need single quotes escaped do so by adding a backslash in front: \'

    hth

    Bjom

      the only problem with your suggestion Bjom is i don't have any control over the string that needs escaping, therefore i can't add the \ by hand, unless there is someway to use PHP to achieve this?

        Why do you need to escape the quotes? The answer to that would determine how you would go about escaping them.

          :S that confused me, bassicaly the problem i have is that for some reason the description of each package isn't being formated by the <br /> tags in the description, i though maybe this is because of the quotes or something, I've spent the last 2-3 hours trying to solve the problem yet its still not working?

          I've tried using str_replace to swap <br /> for <br> yet for some reason it can't find any occurances of <br /> to replace?

            homer09001 wrote:

            bassicaly the problem i have is that for some reason the description of each package isn't being formated by the <br /> tags in the description, i though maybe this is because of the quotes or something

            Ah, so that is your real problem 🙂

            It does not sound like the quotes have anything to do with it, but you should post the relevant source code.

              Packages.template.php (Modified)

              					// Desciption: bleh bleh!
              					// Location of file: http://someplace/.
              					$pakdesc = $txt['package_description'];
              					$descpak = $package['description'];
              
              				echo "
              									<li>", $txt['file_location'] ,":&nbsp; <a href=\"" .$package['href']."\">Download!</a></li>
              									<li class=\"description\">". $txt['package_description'] .": $descpak </li>
              								</ul>";
              			}
              

              Packages.template.php (Original)

              
              				// Desciption: bleh bleh!
              				// Location of file: http://someplace/.
              				echo '
              									<li>', $txt['file_location'], ':&nbsp; <a href="', $package['href'], '">', $package['href'], '</a></li>
              									<li class="description">', $txt['package_description'], ':&nbsp; ', $package['description'], '</li>
              								</ul>';
              			}
              
              

              Output from both pieces of code is identical

                not sure why you want to escape the quotes, or what your problem actually is here, or even how the code sample above relates to your problem, however if you want to automatically escape slashes, you can look at str_replace, addslashes, htmlentities (with the ENT_QUOTES flag) as a starting point. Without being able to figure out what your problem is, however, I'm not sure any of those will be what you are looking for.

                At a guess, from what you have said about br tags, I'll venture that the content is already being run through htmlentities, and thus is displaying the <br> tags (as &lt;br&gt; ) rather than processing them, which has nothing to do with quotes, as a couple of others previously mentioned.

                  $package['description']
                  $txt['package_description']

                  so the problem resides within these variables?

                  to make things perfectly clear you could post the content of one of those variables and also post the pagesource that will be created from that.

                  From what I've seen the above suggestions go in the right direction. I personally prefer the strtr statement and use an array to define what I want to replace so in the end you would change your code along this line:

                  $replace_pairs = array('blah'=>'blub', etc...);
                  echo ' 
                                                          <li>', $txt['file_location'], ':&nbsp; <a href="', $package['href'], '">', $package['href'], '</a></li> 
                                                          <li class="description">', strtr($txt['package_description'], $replace_pairs), ':&nbsp; ', strtr($txt['package_description'], $replace_pairs), '</li> 
                                                      </ul>'; 

                  hth

                  Bjom

                    Write a Reply...