SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Apr 2001
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am running a PHP guestbook script and I give the users an option to leave their AOL Screen Name. When they click on another users Screen Name it brings up an AOL Instant Message directed to that user. Only problem is, if there are any spaces in the user's Screen Name it will throw the link off. So I need to know how to remove the spaces from that field when the user signs the guestbook. Or if I could have the spaces displayed like normal when the users view the entries and have the spaces in the actual "href" tag replaced with a "+" sign (which is how it's supposed to be done) Does that make any sense? Thanks.

  2. #2
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can do this:

    $aol = str_replace(" ", "", $aol); or
    $aol = str_replace(" ", "+", $aol);

    That will work, but there may be a better way.

    Pete

  3. #3
    SitePoint Member
    Join Date
    Aug 2000
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try urlencode($yourstring) to convert spaces and other characters to URL format. See http://www.phpbuilder.com/manual/function.urlencode.php for more details.

  4. #4
    SitePoint Member
    Join Date
    Apr 2001
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think the urlencode string is going to work. Can you help me out and direct me as to how I implement it into the below link? Thanks alot.
    Code:
    <a href=\"aim:goim?screenname=$aim&message=Hi,$aim.\">$aim</a>

  5. #5
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    print "<a href=\"aim:goim?screenname=".urlencode($aim)."&message=Hi,"urlencode($aim) .".\">$aim</a>"
    or

    PHP Code:
    printf('<a href="aim:goim?screenname=%s&message=Hi,%s.">%s</a>'urlencode($aim), urlencode($aim), $aim); 
    Last edited by freddydoesphp; Apr 25, 2001 at 16:19.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  6. #6
    SitePoint Member
    Join Date
    Apr 2001
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the help guys. That did the trick.


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
  •