Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm trying saving an array of an drawn object in google maps api v3.

The MySql table looks like:

CREATE TABLE circles 
(
    lat INT, 
    lng INT, 
    radius INT, 
    fillColor VARCHAR(9), 
    fillOpacity INT
);

The php file save_circle.php:

<?php
$lat = $_REQUEST['lat'];
$lng = $_REQUEST['lng'];
$radius = $_REQUEST['radius'];
$fillColor = $_REQUEST['fillColor'];
$fillOpacity =  $_REQUEST['fillOpacity'];

include 'conn.php';

$sql = "insert into circles(lat,lng,radius,fillColor,fillOpacity)
values('$lat','$lng','$radius','$fillColor','$fillOpacity')";

$result = @mysql_query($sql);
if ($result){
    echo json_encode(array('success'=>true));
} else {
    echo json_encode(array('msg'=>'Some errors occured.'));
}
?>

HTML likes:

google.maps.event.addDomListener(savebutton, 'click', function() {
for (var i = 0; i < circles.length; i++) {
var data = [lat, lng, radius, fillColor, fillOpacity];

/* var data = {
lat: circle.getCenter().lat(),
lng: circle.getCenter().lng(),
radius: circle.getRadius(),
fillColor: circle.get('fillColor'),
fillOpacity: circle.get('fillOpacity'),
}; */

trace(data)
//send the results to the PHP script that adds the circle to the database
$.post("save_circle.php", data, circle.saveStopResponse, "json");
}
});

trace(data) return:

45.108423337694084
-71.8560791015625
22322.63536250027
#ff0000
0.45 

Console return:

[45.108423337694084, -71.8560791015625, 22322.63536250027, "#ff0000", 0.45]
{"msg":"Some errors occured."}

Do I miss something?

Thanks

share|improve this question
 
Did you notice "json" word at the end of your AJAX call? –  Your Common Sense Aug 30 at 13:16
 
What's wrong or what do you mean? –  royseb Aug 30 at 13:18
 
you could start with using mysql_error() to print error messages –  Gerald Schneider Aug 30 at 13:25
 
lat and lng should be type FLOAT, DOUBLE or DECIMAL in db not INT... you dont have primary key defined also –  Ivan HuĆĄnjak Aug 30 at 13:25
 
Sorry guys, I thinks I saw my table error ... –  royseb Aug 30 at 13:26
show 8 more comments

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.