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. :'( Link to comment https://forums.phpfreaks.com/topic/159520-helpjson-urgent/ 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 Link to comment https://forums.phpfreaks.com/topic/159520-helpjson-urgent/#findComment-841458 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... Link to comment https://forums.phpfreaks.com/topic/159520-helpjson-urgent/#findComment-841464 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. Link to comment https://forums.phpfreaks.com/topic/159520-helpjson-urgent/#findComment-841465 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){ ?? Link to comment https://forums.phpfreaks.com/topic/159520-helpjson-urgent/#findComment-841468 Share on other sites More sharing options...
darkfreaks Posted May 25, 2009 Share Posted May 25, 2009 nope still get the error Link to comment https://forums.phpfreaks.com/topic/159520-helpjson-urgent/#findComment-841471 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.. Link to comment https://forums.phpfreaks.com/topic/159520-helpjson-urgent/#findComment-841472 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.