Page 1 of 1
ucwords/strtolower help
Posted: Fri Sep 16, 2005 8:05 pm
by DevTony
Hi I have some trouble here is my code below:
Code: Select all
$Title = ucwords(strtolower($row['Title']));
echo $Title ;
The thing is some of the text has symbols such as ' in the words and when it's echoed it shows up as a ? instead of a ' some help would be nice thanks

.
Posted: Fri Sep 16, 2005 8:16 pm
by s.dot
I don't have that problem when I use the same scenario you are using. Perhaps you're using an unrecognized character set?
A pretty impractical way around it would be:
Code: Select all
$title = ucwords(strtolower($row['Title']));
$newtitle = str_replace("?","'",$title);
echo $title;
This would of course replace any valid question marks with ' so it's a little impractical.
Posted: Fri Sep 16, 2005 8:17 pm
by DevTony
That would work but if I ever did want to use a ? it wouldn't but thanks. Anyone one know anyother way without having to replace the ?.
Posted: Fri Sep 16, 2005 8:42 pm
by jwalsh
is it ' or `, probably a character set issue.
Posted: Fri Sep 16, 2005 9:15 pm
by Charles256
heh. Not that it's the most useful suggestion but you could always check to make sure it's not ? then a space, if it's not a question mark then a space then replace it with a ', otherwise leave it alone. Most people put a space after punctuation so that'd be a work around to your problem though certianly not a fix.
Posted: Sat Sep 17, 2005 7:03 am
by raghavan20
I dont see wot you are saying does happen.
Code: Select all
<form action = '' method = 'get'>
<input type = 'text' value = '' name = 'Title' />
<input type = 'submit' value = 'submit' name = 'sub' />
</form>
<?php
$Title = ucwords(strtolower($_GET['Title']));
echo $Title ;
?>
Code: Select all
dsfdsaf@#$@Q$!#$ Dsfdsaf@#$@q$!#$
sdfsd''''''sdafds Sdfsd\'\'\'\'\'\'sdafds
sdfds??????sdfdsaf Sdfds??????sdfdsaf
sdfs\\/////// Sdfs\\\\///////
If you can infer from the code, as magic_quotes is on, it automatically escapes ' and \. you can strip it and use mysql_escape_string and if the output of ucwords(strtolower($string)) has escape chars you can again run stripslashes()