wow i have NO idea why this is doing this... still a weird character... side note: its a local server so i cant open it up to have anyone look at it :/
hmm i tried but still nothing. It is being inserted correctly as "Crying%Babies" but when it is displayed and returned it freaks out...ughh
i enter in "Crying babies" into the input and it returns "crying�bies" but gets inserted into the db as "Crying%babies" (which i want) but any time it gets returned or displayed it gives me the weird character. and it only happens for certain queries... "winter snow" works fine... It seems like something is happening on the browser end because it does not return any search results as it is looking for "crying�bies" as the keyword. This is my HTML meta <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> i am so stumped..
Good call on the inserting with % (i fixed that now) thanks Here is my query: $query1= "SELECT * FROM curiosities WHERE Curiosity LIKE '"."%".mysql_real_escape_string($Query)."%"."' $sort"; echo for "Winter Snow" SELECT * FROM curiosities WHERE Curiosity LIKE '%winter%snow%' ORDER BY cid ASC echo for "crying babies" SELECT * FROM curiosities WHERE Curiosity LIKE '%crying�bies%' ORDER BY cid ASC
can you do echo ($Query); echo mysql_real_escap_string($Query); PHP: and paste the output of the two here
ok, can you stick the whole of your script on pastebin or something and link to it please. I'm fairly sure its not the input from the form that is messing it up
I am also experiencing this problem in my travel directory myworldtravellinks . com i searched and tried almost everything but get no solution to this special heart sign. I simply leave it as it
I've had a really good look at this, and can't see an error anywhere. I've tested the code, and it works as it should. I notice that in your form you have the id and name of some elements different to each other. Both should be the same, so if you have one called Query you would use <input type="text" id="Query" name="Query" value="default value" /> HTML:
It's really beyond me why you think or want it inserted into the db as "Crying%babies" - the only reason you're getting back this funny � sign is because that's what %ba is being interpreted as by your browser, look into the html source when you see that � and see what value is in there. if it's in utf8 you'll probably see the same thing. still doesn't explain why your insertion isn't just put into the db as you entered it in the first place, i.e. "Crying babies" - if you urlencode it you'd see "Crying%20babies" when inserted, but that's what mysql_real_escape_string is for - even "Crying+babies" would be better.
use this to insert it into mysql $SearchText = str_replace(" ", "%", $SearchText); and after you are done with mysql use $SearchText = str_replace("%", " ", $SearchText); this to display the sarchtext.
the diamond question mark appears when your current HTML encoding, specified in the HTML header (most likely UTF-8) encounters a symbol in a different encoding (most likely ISO-8859-1). a lot of times something will be pasted from microsoft word, it will have an ISO-8859-1 encoding. the solution is to convert the string into UTF-8 encoding: $string = mb_convert_encoding($string, 'HTML-ENTITIES', 'UTF-8');
I just changed the page content type to <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> and the wired sign is no more there. @timallard, did you try that?