Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Aea

macrumors 6502a
Original poster
May 23, 2007
838
208
Denver, Colorado
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*
 
Punching a kitten is never acceptable behavior. :p ;)
 

Attachments

  • attachment.php.jpg
    attachment.php.jpg
    15.9 KB · Views: 297
Punching a kitten is never acceptable behavior. :p ;)

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).
 
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.
 
I was not the one who came up with the picture, sorry for the spelling though anyways... :p :)

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...
 
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.

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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.