G'day.

Firstly, let me apologise for the lack of a link to a live example of
this code.  I've run out of space on my web hosting.

I've been trying to get the code from "From Info Windows to a
Database: Saving User-Added Data" (http://code.google.com/apis/maps/
articles/phpsqlinfo_v3.html) to work locally before going live.  I
have previously edited and managed to get working "Using PHP and MySQL
with Google Maps" (http://code.google.com/apis/maps/articles/
phpsqlajax_v3.html).

Both sets of code use the same database and table.

>From the "Windows to Database" article, I have taken the code for
phpsqlinfo_addrow.php and modified it slightly to suit my database:

"require("phpsqlinfo_dbinfo.php");" has been changed to "require("db-
info.php");"

"// Gets data from URL parameters
$name = $_GET['name'];
$address = $_GET['address'];
$lat = $_GET['lat'];
$lng = $_GET['lng'];
$type = $_GET['type'];"
becomes
"// Gets data from URL parameters
$nodename = $_GET['name'];
//$address = $_GET['address'];
$lat = $_GET['lat'];
$long = $_GET['lng'];
$type = $_GET['type'];"

"$query = sprintf("INSERT INTO markers " .
         " (id, name, address, lat, lng, type ) " .
         " VALUES (NULL, '%s', '%s', '%s', '%s', '%s');",
         mysql_real_escape_string($name),
         mysql_real_escape_string($address),
         mysql_real_escape_string($lat),
         mysql_real_escape_string($lng),
         mysql_real_escape_string($type));"
becomes
$query = sprintf("INSERT INTO table1 " .
         " (id, name, lat, long, type ) " .
         " VALUES (NULL, '%s', '%s', '%s', '%s', '%s');",
         mysql_real_escape_string($name),
         //mysql_real_escape_string($address),
         mysql_real_escape_string($lat),
         mysql_real_escape_string($long),
         mysql_real_escape_string($type));"

When I run the suggested URL query (http://yourdomain.com/
phpsqlinfo_addrow.php?name=Best%20Bar
%20Ever&lat=-37.12345&lng=122.12345&type=bar), I get the following
error: "Invalid query: You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near 'long, type ) VALUES (NULL, 'Best Bar Ever',
'-37.12345', '122.12345', 'bar')' at line 1"

If I revert all instances of "long" back to "lng", I get "Invalid
query: Unknown column 'lng' in 'field list'", which makes sense, since
I don't have a row called "lng" (I use "long" and this works with the
other Google Code example linked above).

If I create a new row called "lng", which seems to be identical in
attributes to "Long", the code works... :|

It seems that SQL queries are not case-specific, so capitalisation
does not seem to be the issue.  I'm a dead-set n00b at this stuff, and
I can't for the life of me figure out what the problem is.  Thanks for
any help.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to