0

i've spend so many time in the net for learning google api v3 from php /mysql but no way.so i begin again asking for validate all the process First my json file, looks like that

{"lat":"46.8529510","lng":"0.5433920","ec_nom":"ANTRAN","ec_type":"ECOLE ELEM","ec_adresse":"PLACE DE L EGLISE","ec_ville":"ANTRAN","ec_cp":"86100"}

all the json file, i've seen looks like

**name[**{"lat":"46.8529510","lng":"0.5433920","ec_nom":"ANTRAN","ec_type":"ECOLE ELEM","ec_adresse":"PLACE DE L EGLISE","ec_ville":"ANTRAN","ec_cp":"86100"}**]**

My code

 $cherch_coordon=mysql_query("SELECT lat, lng,      ec_nom,ec_type,ec_adresse,ec_ville,ec_cp from mouv_0910 WHERE type_nomin='TD' AND oui_mouvement>0  ORDER BY ec_ville ");
$combien=mysql_num_rows($cherch_coordon) ;

  while ($trouv=mysql_fetch_object($cherch_coordon))
        {

          $en_jason=json_encode($trouv) ;
       //$erreur_json=last_error($en_jason);
         echo"$en_jason" ;

So is my json file's valid?

1
  • Are the *s part of the JSON? You cannot bold/italicize text inside code blocks. Commented Apr 13, 2012 at 18:40

1 Answer 1

1

json_encode always prints valid JSON.

{} is for an object, [] is for an array.

P.S.

name[{"lat":"46.8529510","lng":"0.5433920","ec_nom":"ANTRAN","ec_type":"ECOLE ELEM","ec_adresse":"PLACE DE L EGLISE","ec_ville":"ANTRAN","ec_cp":"86100"}]

Is not valid JSON, or vaid anything for that matter.

Did you mean this (note the () instead of [])?

name({"lat":"46.8529510","lng":"0.5433920","ec_nom":"ANTRAN","ec_type":"ECOLE ELEM","ec_adresse":"PLACE DE L EGLISE","ec_ville":"ANTRAN","ec_cp":"86100"})

This is JSONP, not JSON.

Sign up to request clarification or add additional context in comments.

2 Comments

is my file as it is, is valid on javascript request for google maps marker ou should it have this form name({"lat":"46.8529510","lng":"0.5433920",.....,})
THANKS FOR THE SPEED OF THE ANSWER

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.