【发布时间】:2015-01-07 19:04:56
【问题描述】:
我使用这个脚本将数据插入我的数据库:
<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>
我在编译这个脚本时发现了这个错误。我对坐标数据类型使用双精度。
警告:pg_exec() [function.pg-exec]:查询失败:错误:双精度类型的输入语法无效:
【问题讨论】:
-
那么传递给
pg_exec()的字符串$query的值是多少? -
我认为对于 double,您在查询中指定值时不需要添加引号 (
")。
标签: php postgresql