[postgis-users] php/postgresql trouble
Linnet Kwamboka
scientific1quash at gmail.com
Thu Mar 11 00:29:26 PST 2010
hey guys,
i dont know is anyone can help me i have been having trouble.
i am using the follonwing code to do an INSERT query
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head></head>
<body>
<?php
if ($_POST['submit']) {
// attempt a connection
$dbh = pg_connect("host=localhost dbname=postgres user=postgres
password=quash");
if (!$dbh) {
die("Error in connection: " . pg_last_error());
}
else{
echo "this was okay";
}
//exit;
// escape strings in input data
// $code = pg_escape_string($_POST['code']);
//$name = pg_escape_string($_POST['name']);
//$president = pg_escape_string($_POST['president']);
// execute query
$sql = "INSERT INTO countries (CountryID, CountryName, President)
VALUES('{$_POST['code']}', '{$_POST['name']}', '{$_POST['president']}')";
$result = pg_query($dbh, $sql);
if (!$result) {
die("Error in SQL query: " . pg_last_error());
}
echo "Data successfully inserted!";
// free memory
pg_free_result($result);
// close connection
pg_close($dbh);
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Country code: <br> <input type="text" name="code" size="2">
<p>
Country name: <br> <input type="text" name="name">
<p>
President's name: <br> <input type="text" name="president">
<p>
<input type="submit" name="submit">
</form>
</body>
</html>
but i am getting the following error
this was okay
*Warning*: pg_query()
[function.pg-query<http://localhost/bongamate/function.pg-query>]:
Query failed: ERROR: column "countryid" of relation "countries" does not
exist LINE 1: INSERT INTO countries (CountryID, CountryName, President)
VA... ^ in *C:\xampp\htdocs\bongamate\weka.php* on line *25*
Error in SQL query: ERROR: column "countryid" of relation "countries" does
not exist LINE 1: INSERT INTO countries (CountryID, CountryName, President)
VA... ^
can anyone help me on this? thank you
with regards geekmate!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20100311/a0ebc537/attachment.html>
More information about the postgis-users
mailing list