Jump to content
#StayAtHome ×
liderbug

json_encode failing

Recommended Posts

I'm trying to get a Google map to work with polygons.

var points = [
new google.maps.LatLng(39.0174, -104.6634) ,
new google.maps.LatLng(39.0190, -104.6634) ,
new google.maps.LatLng(39.0190, -104.6700) ,
new google.maps.LatLng(39.0174, -104.6700) ];

works just fine.

----------------------

$q1 = mysqli_query ($con, "select * from points;");
while ($r1 = mysqli_fetch_row ($q1)) {
$results[$n++] = "(" . $r1[0] . ")";
}
var points = <?php echo json_encode($results); ?>;


alert (points); in both cases displays the same (39.0174,-104.6634... numbers.  Except the sql doesn't display anything - well the map but not the polygon.

I'd love any help you can give.
Thanks

 

 

Share this post


Link to post
Share on other sites

Do a View Source of your page, and find the line where you outputted $results. Does the Javascript look correct?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.