Link to home
Start Free TrialLog in
Avatar of jblayney
jblayneyFlag for Canada

asked on

escaping single quotes in php output.

Hello,

I am generating a google map using advanced custom fields, it works great except that I have a lot of French text and they used single quotes all over the place, the single quotes are breaking my google map output..

I tried wrapping my field (   the_field('street_address')     ) in esc_html(), esc_html() and  esc_attr() with no luck..

var contentString<?php echo $post->ID; ?> = '<div id="content">'+

      '<div id="siteNotice">'+

      '</div>'+

     '<h3 id="firstHeading" class="firstHeading"><?php the_title(); ?></h3>'+

      '<div id="bodyContent">'+

      '<p><b>Address:</b> <br /><?php echo the_field('street_address'); ?>, <?php echo the_field('city'); ?><br /> ' +

      '<?php echo the_field('postal_code'); ?><br><br />' +

	  '<b><a href="<?php echo the_field('website'); ?>" target="_blank">Visit website</a></b><br />' +

       '<b><span>Distance: <?php echo get_the_distance(null, 1); ?> KM </span></b><br />' +
	   
	   '</p>'+

      '</div>'+

      '</div>';

Open in new window

Avatar of kenfcamp
kenfcamp
Flag of United States of America image

Avatar of jblayney

ASKER

Hello,
Yes I did.. It didn't work. Also this is output to page, not entering into DB
i wondering if it is because it is an ACF (Advanced Custom Fields) field
I frequently meet this problem.
The simplest way I have found is to replace the apostroph by an acute accent
&#180;      &#xB4;      &acute;

The look is almost the same....
Consider changing that in your datafile as well as when processing it thru php

(Just for the fun: my village name has an apostroph. When buying anything online, if I leave the apostroph anything can happen during the data transfers between the different carriers )
ASKER CERTIFIED SOLUTION
Avatar of jblayney
jblayney
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thank you