joycecwj Posted May 25, 2009 Share Posted May 25, 2009 function save(){ var finalpoint=marker.getPoint(); eval(finalpoint); var js=json_encode(finalpoint); $.post('em.php',js, function(json){ //$("#add-point .error").fadeOut(); if (json.status == "fail") { $("#add-point .error").html(json.message).fadeIn(); } if (json.status == "success") { $("#add-point :input[name!=action]").val(""); var location = json.data; alert(location); } }, "json"); } this is my javascript. i want to pass the finalpoint to php....but its didnt work...HELP~~~ $geocode=$_POST['finalpoint']; echo "here".$geocode; $chunks = spliti (",", $geocode); $lat= $chunks[0]; $lng= $chunks[1]; $query="UPDATE employer SET lat='$lat', lng='$lng' WHERE id='1' ;"; $res = mysql_query($query); if ($res) { success(array('lat' => $lat, 'lng' => $lng)); } else { fail('Failed to add point.'); } exit; } function map_query($query) { // Connect mysql_connect('localhost', 'root', '') OR die(fail('Could not connect to database.')); mysql_select_db('map'); return mysql_query($query); } function fail($message) { die(json_encode(array('status' => 'fail', 'message' => $message))); } function success($data) { die(json_encode(array('status' => 'success', 'data' => $data))); } here is the php. :'( Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted May 25, 2009 Share Posted May 25, 2009 syntax error, unexpected TINVALID, expecting '{' or '[' at line 1 Parsing failed Quote Link to comment Share on other sites More sharing options...
joycecwj Posted May 25, 2009 Author Share Posted May 25, 2009 syntax error, unexpected TINVALID, expecting '{' or '[' at line 1 Parsing failed the php code or java? but when i load the page there is no error on page... Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted May 25, 2009 Share Posted May 25, 2009 i ran your code through a Json parser thats the error it returned. Quote Link to comment Share on other sites More sharing options...
joycecwj Posted May 25, 2009 Author Share Posted May 25, 2009 i ran your code through a Json parser thats the error it returned. how bout if i replace the line from $.post('em.php',js, function(json){ to $.post($("#add-point").attr('action'),data, function(json){ ?? Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted May 25, 2009 Share Posted May 25, 2009 nope still get the error Quote Link to comment Share on other sites More sharing options...
joycecwj Posted May 25, 2009 Author Share Posted May 25, 2009 nope still get the error :'( can you help me check?? i have no idea anymore... i'm newbie i think bout tis part 2 days d..T.T and its quite urgent... thank.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.