I use this script to insert data to my database:
<html>
<body>
<?php
include('koneksi.php');
$gid = pg_escape_string ($_POST['gid']);
$nama = pg_escape_string ($_POST['nama']);
$alamat = pg_escape_string ($_POST['alamat']);
$no_telfon = pg_escape_string ($_POST['no_telfon']);
$email = pg_escape_string ($_POST['email']);
$website = pg_escape_string ($_POST['website']);
$longitude = pg_escape_string ($_POST['longitude']);
$latitude = pg_escape_string ($_POST['latitude']);
$query = "INSERT INTO perguruantinggi( gid, nama, alamat, no_telfon, email, website, longitude, latitude )
VALUES ('" . $gid . "', '" . $nama . "', '" . $alamat . "', '" . $no_telfon . "', '" . $email . "', '" . $website . "', '" . $longitude . "', '" . $latitude . "')";
$result = pg_exec($query);
//$query = "INSERT INTO perguruantinggi (username, password, fullname, email, agama, no_hp)
//VALUES ('" . $username . "', '" . $password . "', '" . $email . "', '" . $fullname . "', '" . $agama . "', '" . $no_hp . "')" ;
if (!$result) {
$errormessage = pg_last_error();
echo "Error with query: " . $errormessage;
exit();
}
printf ("These values were inserted into the database - %s %s %s", $firstname, $surname, $emailaddress);
pg_close();
?>
</body>
I found this error when I compile this script. I use double precision for coordinate data type.
Warning: pg_exec() [function.pg-exec]: Query failed: ERROR: invalid input syntax for type double precision:
$query
which is passed topg_exec()
? – Michael Berkowski"
) when you specify the values in your query. – Yohanes Khosiawan 许先汉