htmlentities not suddenly not working!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lettie_dude
Forum Commoner
Posts: 65
Joined: Thu Dec 07, 2006 10:10 am

htmlentities not suddenly not working!

Post by lettie_dude »

Today I have discovered a few of my sites are not drawing information from the database and displaying it properly. The issue seems to be with a call to htmlentities function displaying text from a blob database entry.

The error message is as follows

htmlentities() [function.htmlentities]: Invalid multibyte sequence in argument

I imagine because this is effecting several sites it is something my hosting company has changed on the servers and not informed me. Can anyone shed any light on why this is happening and what the remedy may be. I don't fancy having to re-write code that has been working perfectly well for over 12 months!!

The code calling the function is as follows:

Code: Select all

$output['story'] = htmlentities($databasevariable[0], ENT_QUOTES, 'UTF-8');
$databasevariable[0] is the blob called from the database.

Cheers
lettie_dude
Forum Commoner
Posts: 65
Joined: Thu Dec 07, 2006 10:10 am

Re: htmlentities not suddenly not working!

Post by lettie_dude »

Update to this.

I have now removed the UTF-8 conversion parameter and the function seems to work fine. I would still like to know if this is due to the release of php 5.2.6 or it is something that my hosting company have changed which has effected it? If it is them I will cetainly be looking elsewhere for hosting as this is the latest in a barage of similar incidents!!!
suresh_2220
Forum Newbie
Posts: 23
Joined: Mon May 12, 2008 3:13 pm

Re: htmlentities not suddenly not working!

Post by suresh_2220 »

I think it bcz of your hosting company may have upgraded the PHP server from 4 to 5.1 . so some functions won't work as you expect in newer version. plz visit http://php.net for more details
lettie_dude
Forum Commoner
Posts: 65
Joined: Thu Dec 07, 2006 10:10 am

Re: htmlentities not suddenly not working!

Post by lettie_dude »

They have indeed upgraded php. But to version 5.2.6 and this was back in Feb and everything has been working fine since then. This only happened in the last 3 days and effected all sites using the above code. I am currently going through removing the UTF-8 parameter so that they work. The hosting company have been less than helpful and are virtually saying its not them! Not the first time this has happened. I'm more or less expecting it to suddenly correct itself with no word from them! Anyway I'd be interested to know if anyone else has experienced the problem with the htmlentities function and what could be causing it not to work on some database blog entries and not others with the error code:

htmlentities() [function.htmlentities]: Invalid multibyte sequence in argument
kaliok08
Forum Newbie
Posts: 1
Joined: Sat May 17, 2008 5:31 pm

Re: htmlentities not suddenly not working!

Post by kaliok08 »

Hi I have the exact same problem... I wasn't able to fix it other than doing something similar to you. However, I found/thought it wasn't the 3rd parameter of htmlentities causing the problem, but the 2nd. When I left the 2nd parameter in there:

$testX=htmlentities($paragraph,ENT_QUOTES);

It still didn't work.

I believe that BOTH the 2nd and 3rd parameters are optional...in the end the only way I was able to get it to work was using the following:

$testX=htmlentities($paragraph);

I had to go through all the code and change it to the above.

It wasn't a solution I was happy with it...

BTW...The host you are talking about wouldn't happen to begin with an F and end in and S would it? I didn't bother calling my host this time, as I to have found they won't admit to anything too, and usually but always 'miraculously' the problem is corrected...

How have you got on?
Post Reply