SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist Caesar's Avatar
    Join Date
    May 2000
    Location
    On some harddisk
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Couple of questions

    Hi,

    1) Is there anyway where I can temporarily escape from htmlspecialchars() function?

    (The reason: I'm building a snippets function and sometimes I would like to store html codes to display to users. Without htmlspecialchars(), those html codes (which are stored in mysql tables) will be intepreted by the browser. On the other hand, I might like to use tags like <i> to emphasize certain source codes of languages such as PHP and so forth.) Anyone have ideas?

    2) How do I parse a parameter string that has a space in it?

    For example,

    Code:
    //script.php
    $name=$query_data["name"] //$name="java applet"
    <a href=next.php?name=$name>Link</a>
    Code:
    //next.php
    echo $name; //it will print out "java" instead of "java applet".
    Any ideas?
    Last edited by Caesar; Jan 5, 2002 at 19:45.

  2. #2
    SitePoint Zealot
    Join Date
    Jun 2000
    Location
    Yeppoon, Australia
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1) Is there anyway where I can temporarily escape from htmlspecialchars() function?

    The way you have done this with HTML that you want shown and other that you want actually for the browser is rather difficult.

    Instead, like this forum, use your own codes with the [] brackets for the bits that you eventually want converted to HTML for the browser (for bold, italics, etc). htmlspecialchars() won't touch them and you can use regular expressions to replace them with the appropriate HTML source code. Take a look at Kevin's php/mysql book/tutorial for the code to do this.


    2) How do I parse a parameter string that has a space in it?

    Use the urlencode() function on the parameter something like this:

    PHP Code:
    echo '<a href="mycgi?foo='urlencode($userinput), '">'
    Before using that parameter in the target page you'd use urldecode() on it to get back all the words.

    See the php manual for the full details on these.
    Knowledge is knowing that a tomatoe is a fruit; wisdom is not putting it in a fruit salad.


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
  •