stublackett Posted April 9, 2009 Share Posted April 9, 2009 Hi, Just working on a Football Clubs' website and I have a match report pulling through, But when its pulling through apostrophes and speech marks. The characters are coming out as squares in IE and small diamond shaped question marks in FireFox. How do I tell PHP just to output the character as an apostrophe? An example of what I mean is at : http://www.berwickrangers.net/test/report.php?reportID=1 As you can see from this exert : Berwick Rangers turned in one of their best 45 minute spells of the last five years to blow title hopefuls East Stirling off the park in a superb match at Ochilview on Saturday. Darren Gribben grabbed the headlines with a slickly-taken hat-trick, but it was Rangers� It should say Rangers' at the end not a � I've tried stripslashes but no joy. Any help appreciated Quote Link to comment https://forums.phpfreaks.com/topic/153317-apostrophes-speech-marks-pulling-through-strangely/ Share on other sites More sharing options...
redarrow Posted April 9, 2009 Share Posted April 9, 2009 you need to re format the ' to html special characters. http://www.utexas.edu/learn/html/spchar.html or use. http://uk3.php.net/htmlspecialchars Quote Link to comment https://forums.phpfreaks.com/topic/153317-apostrophes-speech-marks-pulling-through-strangely/#findComment-805468 Share on other sites More sharing options...
taquitosensei Posted April 9, 2009 Share Posted April 9, 2009 or change your encoding in your headers. If it's set to UTF-8 now try iso-8859-1 or vice versa Quote Link to comment https://forums.phpfreaks.com/topic/153317-apostrophes-speech-marks-pulling-through-strangely/#findComment-805475 Share on other sites More sharing options...
Axeia Posted April 9, 2009 Share Posted April 9, 2009 or change your encoding in your headers. If it's set to UTF-8 now try iso-8859-1 or vice versa And the meta tag, for IE. Quote Link to comment https://forums.phpfreaks.com/topic/153317-apostrophes-speech-marks-pulling-through-strangely/#findComment-805482 Share on other sites More sharing options...
stublackett Posted April 9, 2009 Author Share Posted April 9, 2009 or change your encoding in your headers. If it's set to UTF-8 now try iso-8859-1 or vice versa And the meta tag, for IE. How do I achieve that Axeia? I've tried setting it as htmlspecialchars <?php echo htmlspecialchars ($report); ?> But its coming out like this : erwick Rangers turned in one of their best 45 minute spells of the last five years to blow title hopefuls East Stirling off the park in a superb match at Ochilview on Saturday. Darren Gribben grabbed the headlines with a slickly-taken hat-trick, but it was Rangers� teamwork which destroyed one of the best Shire sides in recent memory. Shire had come into the match as the Third Division�s form outfit, with six wins from their previous seven matches. The margin of Rangers� victory looked an unlikely prospect at half time after Shire had embarked on a mini-blitzkrieg following Gribben�s opener, but such was the extent of the Gers� domination after the break that they could have won by seven or eight clear goals.<br /> <br /> and those damn Diamond things are still there ??? Quote Link to comment https://forums.phpfreaks.com/topic/153317-apostrophes-speech-marks-pulling-through-strangely/#findComment-805495 Share on other sites More sharing options...
stublackett Posted April 9, 2009 Author Share Posted April 9, 2009 Just as a headsup and a question really.... Is it better when inserting to the Database to put htmlspecialchars on the string?? i.e <?php $report = htmlspecialchars($report); ?> Quote Link to comment https://forums.phpfreaks.com/topic/153317-apostrophes-speech-marks-pulling-through-strangely/#findComment-805539 Share on other sites More sharing options...
stublackett Posted April 15, 2009 Author Share Posted April 15, 2009 Apologies for propping this back up, But still had no joy with this at all ??? ??? Quote Link to comment https://forums.phpfreaks.com/topic/153317-apostrophes-speech-marks-pulling-through-strangely/#findComment-810730 Share on other sites More sharing options...
JonnoTheDev Posted April 15, 2009 Share Posted April 15, 2009 Try this on the variable that contains the text $report = mb_convert_encoding($report, "ISO-8859-1", "auto"); echo $report; I bet its characters that are copied and pasted from microsoft word. Quote Link to comment https://forums.phpfreaks.com/topic/153317-apostrophes-speech-marks-pulling-through-strangely/#findComment-810735 Share on other sites More sharing options...
stublackett Posted April 15, 2009 Author Share Posted April 15, 2009 I'm getting Fatal error: Call to undefined function mb_convert_encoding() The code is in an include file titled "match-report.php" <?php include ("dbconnect.php"); # Connect to PHPMyAdmin DB $db = mysql_connect($hostname, $db_user, $db_password); mysql_select_db($dbname,$db); error_reporting(E_ALL); $result = mysql_query("SELECT *, DATE_FORMAT( date, '%W %D %M %Y' )AS uk_date FROM $db_table4 WHERE reportID='$_GET[reportID]'"); while($myrow = mysql_fetch_assoc($result)) {//begin of loop $reportID = $myrow['reportID']; $headline = $myrow['headline']; $reportdate = $myrow['uk_date']; $location = $myrow['location']; $attendance = $myrow['attendance']; $lineup = $myrow['lineup']; $lineup = nl2br($lineup); $scorers = $myrow['scorers']; $bookings = $myrow['bookings']; $report = $myrow['report']; $report = nl2br($report); $image1 = $myrow['image1']; $image2 = $myrow['image2']; $image3 = $myrow['image3']; $image4 = $myrow['image4']; }//End While loop ?> Then I'm just echoing $description in the report.php page. As so : <?php $report = mb_convert_encoding($report, "ISO-8859-1", "auto"); echo $report; ?> Quote Link to comment https://forums.phpfreaks.com/topic/153317-apostrophes-speech-marks-pulling-through-strangely/#findComment-810749 Share on other sites More sharing options...
JonnoTheDev Posted April 15, 2009 Share Posted April 15, 2009 Fatal error: Call to undefined function mb_convert_encoding() You need the mbstring extension compiled into php for this to work. Are you on a shared server or is this your own? Windows or Linux? Quote Link to comment https://forums.phpfreaks.com/topic/153317-apostrophes-speech-marks-pulling-through-strangely/#findComment-810757 Share on other sites More sharing options...
stublackett Posted April 15, 2009 Author Share Posted April 15, 2009 Its hosted by Fasthosts ??? and the server is a shared Windows Server. Quote Link to comment https://forums.phpfreaks.com/topic/153317-apostrophes-speech-marks-pulling-through-strangely/#findComment-810761 Share on other sites More sharing options...
JonnoTheDev Posted April 15, 2009 Share Posted April 15, 2009 Its hosted by Fasthosts and the server is a shared Windows Server. Oh well, never mind. What that function will do is detect the encoding of the string and convert it to ISO-8859-1. Probably would of worked. If you can add extensions to php through your webhost's control panel then I would try. Its the mbstring extension that you need: http://uk3.php.net/manual/en/book.mbstring.php Quote Link to comment https://forums.phpfreaks.com/topic/153317-apostrophes-speech-marks-pulling-through-strangely/#findComment-810768 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.