SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist Worldbuilder's Avatar
    Join Date
    Jan 2004
    Location
    Boston, MA
    Posts
    481
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Gotta replace "&" in my search results page. Can I?

    Hello one and all,

    I don't know if what I would like to do is possible or not, but if it is, I would greatly appreciate help with it.

    I use a php search script for my website. Simple enough. I'm big on XHTML validation, too. Now, I realized quickly that the OUTPUT of the searches were not going to be able to be made XHTML 1.0 valid just because of the way it's written. BUT I did try to get it to validate as HTML 4.01 at least. Well, I did except for one thing.

    For example, check out this page of results. It DOES validate as HTML 4.01. Cool.

    However, try this results page. Basically the same page, but with a different result because of a different search. This results page does NOT validate. BUT it only doesn't validate because of "&"s in the URL's that are generated by the search. That's all. Obviously, if I could just edit the HTML it would be an easy fix, but I can't do that because the pages are php-generated.

    Is there some way to edit the search.php file (which controls the output and is what I've attached as a zip file) to replace all the "&"s in URL's with "&"?

    If so, could someone please show me how? I'm very much a novice with php.

    Thanks!

    Chris
    Attached Files Attached Files

  2. #2
    SitePoint Member
    Join Date
    Jul 2005
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You probably want to wrap the output in the htmlentities function.

  3. #3
    SitePoint Evangelist Worldbuilder's Avatar
    Join Date
    Jan 2004
    Location
    Boston, MA
    Posts
    481
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jimrthy
    You probably want to wrap the output in the htmlentities function.
    Forgive me, but I have no idea what that is, or if it will accomplish what I desire. What is that, and will it?

    Thanks for the reply!

    Chris

  4. #4
    SitePoint Evangelist Worldbuilder's Avatar
    Join Date
    Jan 2004
    Location
    Boston, MA
    Posts
    481
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you mean lines 276 - 269?
    PHP Code:
    $entitiesQuery htmlspecialchars($query);
        if (
    $result==0)
            print 
    "<table width=\"100%\" class =\"resultReport\"><tr><td>".$sph_messages["The search"]." \"$entitiesQuery\" ".$sph_messages["noMatch"].".</td></tr></table>"
    Will something in this code help me? Is there a way for me to tell the script to put an "&amp;" wherever it encounters an "&"?

    Chris

  5. #5
    SitePoint Zealot metacube's Avatar
    Join Date
    Jun 2005
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, that's what htmlentities() does.
    Wherever you output something to the page, pass it through htmlentities() to change th & to &amp;


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •