Code:
<html>
<body>
<?php
$PGHOST = localhost;
$PGDATABASE = "SantaRosaDB";
$PGUSER = "postgres";
$PGPASSWORD = "Casabubu25";
$PGPORT = 5432;
$db_handle = pg_connect("dbname=$PGDATABASE user=$PGUSER
password=$PGPASSWORD");
if ($db_handle) {
echo 'Connection attempt succeeded.';
} else {
echo 'Connection attempt failed.';
}
$cropid = intval( $_POST['cropid']);
$crop_type = pg_escape_string($_POST['crop_type']);
$crop_name = pg_escape_string($_POST['crop_name']);
$cultivation_yrs = intval( $_POST['local_names']);
$local_name = pg_escape_string($_POST['cultivation_yrs']);
$query = "INSERT INTO crops (cropid,crop_type,crop_name,local_name, cultivation_yrs)VALUES(nextval('cropid_seq') '$crop_type', '$crop_name', '$local_name', '$cultivation_yrs')";
$result = pg_query($query);
if (!$result) {
$errormessage = pg_last_error();
echo "Error with query: " . $errormessage;
exit();
}
printf ("These values were inserted into the database - %s %s %s %s %s",$crop_id,$crop_type,$crop_name,$cultivation_yrs,$local_name);
pg_close();
?>
</body>
</html>
Warning: pg_query() [function.pg-query]: Query failed: ERROR: type "nextval" does not exist LINE 1: ...type,crop_na me,local_name, cultivation_yrs )VALUES(nextval ('c... ^ in C:\ms4w\Apache\ htdocs\php\inpu tcrops.php on line 22
Error with query: ERROR: type "nextval" does not exist LINE 1: ...type,crop_na me,local_name, cultivation_yrs )VALUES(nextval ('c... ^
Error with query: ERROR: type "nextval" does not exist LINE 1: ...type,crop_na me,local_name, cultivation_yrs )VALUES(nextval ('c... ^
Comment