[B]
I am just trying to upload gps routes with this application – http://trekhotel.com/bina/upload.php , however there are happens an unexpected bug in the query with PHP function and MySQL database.
The php function source code used for the points
upload in the database is that - geodb.class.php :
<?php
function inputRouteTrack($routeId, $points) {
$query = "INSERT INTO `geo_points` (`id`, `route`, `lat`, `lng`,
`alt`, `time`)";
foreach($points as $p) {
$pnts[] = "(NULL, $routeId, '".floatval($p->lat)."',
'".floatval($p->lng)."', '".floatval($p->alt)."', '".intval($p->time)."')";
}
$query .= " VALUES ".implode(',',$pnts);
$res = $this->query($query);
return $this->affected;
}
?>
The MySQL dump for the table below :
-- phpMyAdmin SQL Dump
-- version 3.2.4
-- http://www.phpmyadmin.net
--
-- Server: localhost
-- Time: Fev 24, 2010 06:12 PM
-- Server version : 5.0.89
-- PHP version : 5.2.9
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE TABLE IF NOT EXISTS `geo_points` (
`id` int(11) NOT NULL auto_increment,
`route` int(11) NOT NULL default '0',
`lat` float NOT NULL default '0',
`lng` float NOT NULL default '0',
`alt` float NOT NULL default '0',
`time` int(11) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=9540 ;
The XML file uploaded very well , however the inserting
points ( lat,lng ) into table failed and return these
errors :
"Warning: Invalid argument supplied for foreach() in /home/trekhote/
public_html/bina/core/geodb.class.php on line 221
Warning: implode() [function.implode]: Invalid arguments passed in /
home/trekhote/public_html/bina/core/geodb.class.php on line 224
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 ‘’ at line 1 "
I make var_dump($pnts) to debug and it returns NULL.
Please if someone can help me about thank you very
much !
Djalma Bina.
[/B]