1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Question marks ?? in my text

Discussion in 'PHP' started by cagintranet, Jun 8, 2006.

  1. #1
    I think my PHP parser is not formatting my text right. I get question marks anywhere there should be a single quote in my text.

    You can see it on my Clevelandbloogers.com site.

    Does anyone know how to get rid/prevent of these?

    I thought about throwing the text through the htmlentities() script but the problem, i only want to replace the single quotes, not all the other stuff that htmlentities() changes to html text.

    Any ideas?
     
    cagintranet, Jun 8, 2006 IP
  2. sketch

    sketch Well-Known Member

    Messages:
    898
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    148
    #2
    Your site appears to be down right now :(

    My guess is you wrote your text in a program like Word and copy/pasted that into your website. Programs like Word automatically will turn plain (straight) quotes into curly quotes, which PHP doesn't recognize. If possible, convert all your text to ASCII before entering it into your site OR add code to your script to automatically handle non-ASCII characters.
     
    sketch, Jun 8, 2006 IP
  3. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #3
    I agree with sketch, about it sounding like MS word chars in your string. The most common problem makers are dashes - vs —, quotes " vs “” and apostrophes ' vs ‘.
     
    jestep, Jun 9, 2006 IP
  4. cagintranet

    cagintranet Well-Known Member

    Messages:
    328
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    128
    #4
    Huh... the site is fine for me now. It better not have gone down...stupid godaddy

    The problem is that i am using a feed aggregater to pull feeds into my site. These blogs' posts are whats being converted into the ?'s

    Is there a php script that can get rid of these?
     
    cagintranet, Jun 9, 2006 IP
  5. decepti0n

    decepti0n Peon

    Messages:
    519
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Although I can't really see exactly whats wrong,
    str_replace("?", "'", $text);
    Code (markup):
    would replace all question marks with apostrophes in $text (generally the content of the article/whatever it is.

    Although im not too great with feeds etc, wouldn't know how to apply it

    edit: the reason your site is 'down' is because the url is wrong ;)
     
    decepti0n, Jun 9, 2006 IP
  6. sketch

    sketch Well-Known Member

    Messages:
    898
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    148
    #6
    If it's from a feed you don't have control over, then you'll definitely have to look into a script to convert those characters.

    Unfortunately deceti0n's script isn't good enough as it will replace actual question marks at the end of a question with the single apostrophe. When PHP doesn't recognize a special character, it's not actually putting out a ?, it's putting out some bizarre character that your browser or system doesn't recognize. So it's actually a combination of PHP and your system outputting those ?s.
     
    sketch, Jun 9, 2006 IP
    cagintranet likes this.
  7. cagintranet

    cagintranet Well-Known Member

    Messages:
    328
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    128
    #7
    ooohh that makes sense. Thanks Sketch. I will just have to keep track of which sites are doing it - and then find out which characters are causing the problem ?'s.
     
    cagintranet, Jun 9, 2006 IP