Wanting to punch a kitten is probably the appropriate response here [PHP]

Discussion in 'Web Design and Development' started by Aea, Jun 29, 2007.

  1. Aea macrumors 6502a

    Aea

    Joined:
    May 23, 2007
    Location:
    Denver, Colorado
    #1
    I'm having a major problem getting the most minor part of my code to work...

    I have a script which searches for bullets (•), the search, etc works (whenever I try anything other then a bullet, like a star for example), and it even works on one of my scripts, but the same exact script with a different name, nope, doesn't work...

    Code:
    <?
    function make_list($form_input)
    {
    echo "Making List";
    $list_begin = strpos($form_input, "• ");
    $form_size = strlen($form_input);
    	if ($list_begin != FALSE OR substr($form_input, 0, 2) == "• ")
    		{
    			$form_input = substr($form_input, 0, $list_begin)."<ul>\n<li>\n\t".substr($form_input, ($list_begin+2), $form_size)."\n</li>\n</ul>";
    			$form_input = str_replace("• ", "</li>\n<li>\n\t", $form_input);
    		}
    return $form_input;
    }
    
    
    //error_reporting(0);
    $form_input = $_POST['content'];
    
    echo "My Input : ".$form_input."<br />";
    
    echo "<br /><br />".make_list($form_input)."<br /><br />";
    
    ?>
    
    I know it's ugly, because it's simplified. Same identical code, different results, one doesn't even find that the bullet exists.


    Oh, and here's some debugging information...

    [-@- -]# md5sum ****.php
    10a2a949abc490464b966c37aa650ecb ****.php

    [-@- -]# md5sum test.php
    10a2a949abc490464b966c37aa650ecb test.php


    So I found the problem, but not that's causing it?

    I send • asdsa • asdsa • asdsa through the form, it comes out different on both sides even though the code is completely identical, one adds random tags instead of the bullet, the other one does it right, any ideas?

    I just tested in Firefox vs IE, this problem doesn't exist in IE, how ironic. *shakes head*
     
  2. dmw007 macrumors G4

    dmw007

    Joined:
    May 26, 2005
    Location:
    Working for MI-6
    #2
    Punching a kitten is never acceptable behavior. :p ;)
     

    Attached Files:

  3. jng macrumors 65816

    jng

    Joined:
    Apr 6, 2007
    Location:
    Germany
    #3
    You spelled "hey" wrong :p

    Aea, what are you trying to do with your code? It seems to me that searching for a bullet character is kind of odd...As for it working only in IE, it probably has to do with how browsers handle other characters, like bullets (which shouldn't be in forms anyway).
     
  4. dmw007 macrumors G4

    dmw007

    Joined:
    May 26, 2005
    Location:
    Working for MI-6
    #4
    I was not the one who came up with the picture, sorry for the spelling though anyways... :p :)
     
  5. Super Macho Man macrumors 6502a

    Super Macho Man

    Joined:
    Jul 24, 2006
    Location:
    Hollywood, CA
    #5
    Since the md5sum is the same on both files, I doubt it's a PHP problem. I would suspect a character set problem. The bullet is a Unicode character and will appear as text gibberish in another character set. I believe Firefox by default requests documents in ISO-8859-1 character set? What happens when you change it to UTF8? Could you try replacing the bullet with the bullet HTML entity ( • ) in the code?

    I don't know why it would happen with one filename but not another though, maybe a caching issue.
     
  6. jng macrumors 65816

    jng

    Joined:
    Apr 6, 2007
    Location:
    Germany
    #6
    Where do people find these things? Just out of curiosity. I've seen them around. Is there a specific site for them? I thought MR members were making them as they went...
     
  7. Aea thread starter macrumors 6502a

    Aea

    Joined:
    May 23, 2007
    Location:
    Denver, Colorado
    #7
    That would probably be the issue, the reason for this code is that people paste in from PDFs lists which are outputted into neat, formatted html, the site itself is more of a usability project then anything else, but it at least has to work.

    I can't seem to consistently replicate this problem, the most common accessed browser will be IE, but there are Firefox users as well. The two pages could be completely identical, the input pasted from a PDF (identical stuff pasted in), a tampering of the sent form data reveals that in some cases the bullet is sent as two arcane characters instead of the actual bullet (grr). I was practically using the same code a few days ago and it worked fine, now it's not, and I'm seeking a fix.
     
  8. Aea thread starter macrumors 6502a

    Aea

    Joined:
    May 23, 2007
    Location:
    Denver, Colorado
    #8


    http://en.wikipedia.org/wiki/Lolcat
     

Share This Page