我将尝试使用ST_Makepoint和get值进行插入,但遇到了500错误。
这是我的php代码:
<?php
try {
$user = 'user';
$dbh = new PDO('pgsql:host=localhost;dbname=userdb', $user);
$stmt = $dbh->prepare("INSERT INTO table(id_a, id_b, geom) VALUES (?,?,?);");
if ($stmt->execute(array($_GET['id_a'], $_GET['id_b'], ST_SetSRID(ST_MakePoint($_GET['lat'], $_GET['long']),4326)))) {
print_r("OK");
} else {
print_r("Error");
}
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
如果我在pgAdmin中运行此查询,则会成功:
INSERT INTO table(id_a, id_b, geom) VALUES (1,1,ST_SetSRID(ST_MakePoint(2, 2),4326));
你知道如何修复php代码中的问题吗?
INSERT INTO table(id_a, id_b, geom) VALUES (?,?,?);
但是在你的结果中,你正在使用表posizioni
,所以尝试编辑你的INSERT为:INSERT INTO posizioni(...
- pes502