php - insert postgis geometry with GET values -


i'm trying make insert using st_makepoint values, run 500 error.

this php code:

<?php try {     $user = 'user';     $dbh = new pdo('pgsql:host=localhost;dbname=userdb', $user);       $stmt = $dbh->prepare("insert 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(); } ?> 

if run query pgadmin, runs well:

insert table(id_a, id_b, geom) values (1,1,st_setsrid(st_makepoint(2, 2),4326)); 

do know how fix problem in php code?

i solved in way:

$stmt = $dbh->prepare("insert table(id_a, id_b, geom) values (?,?,st_setsrid(st_makepoint(?, ?),4326));");      if ($stmt->execute(array($_get['id_a'], $_get['id_b'], $_get['lat'], $_get['long']))) {         print_r("ok");     } else {         print_r("errore");     } 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -