htmlentities() expects at least 1 parameter, 0 given

[php]header(‘Content-Type: text/xml’);

// Iterate through the rows, adding XML nodes for each

while ($row = @mysql_fetch_assoc($result)){
$node = $dom->createElement(“marker”);
$newnode = $parnode->appendChild($node);
$newnode->setAttribute(“address”, $row[‘address’]);
$newnode->setAttribute(“lat”, $row[‘lat’]);
$newnode->setAttribute(“lng”, $row[‘lng’]);
$newnode->setAttribute(“type”, $row[‘type’]);
$newnode->setAttribute(“event”, $row[‘event’], htmlentities(), ENT_QUOTES, “utf-8”);
$newnode->setAttribute(“link”, $row[‘link’]);


echo $dom->saveXML();


Basically the the ‘event’ row has information that needs to be using utf-8 but trying to figure out how to use the htmlentities correctly.

Any help would be greatly appreciated.

This is the correct usage of htmlentities() function:
[php]$newnode->setAttribute(“event”, htmlentities($row[‘event’], ENT_QUOTES, “utf-8”));[/php]

Thank you so much for that.

One last thing is there a easy enough way to output the pound symbol within this script as the ‘event’ row has information with prices?

This function should encode pound sign properly, try to check:
[php]echo htmlentities(‘£’, ENT_QUOTES, “utf-8”);[/php]

It’s just ouputting the same with the pound sign not showing.

Look at HTML source code, htmlentities() function will encode pound as £

Looked and the £ is not there, its a map if that makes a difference.

Not sure what kind of map do you mean, did you try this simple code alone?
echo htmlentities(‘£’, ENT_QUOTES, “utf-8”);

just create a file, put this code there, and see what result it will produce. Use browser that allows to view HTML source code.

Sponsor our Newsletter | Privacy Policy | Terms of Service