pg_query查询失败:ERROR整数的输入语法无效

时间:2018-03-23 11:50:46

标签: syntax-error pg-query

在提交时收到错误消息。

  

警告:pg_query():查询失败:错误:无效的输入语法   整数:" 2018-03-11"第1行:插入反馈2值   (' 2018-03-11',' 1',' 1',' 1',' 1'。 .. ^ in   第37行/var/www/html/form/feedback.php

加载页面时,我会看到以下内容

  

警告:pg_query():查询失败:错误:无效的输入语法   整数:""第1行:插入反馈2价值观('''','','''&# 39 ;,   第37行的/var/www/html/form/feedback.php中'','','')^

我做错了什么?????

数据库创建

CREATE TABLE IF NOT EXISTS public.feedback2
(
  idx integer NOT NULL,
  date date,
  location character varying,
  course character varying,
  trainer character varying,
  trainer_expertise integer,
  trainer_presentation integer,
  trainer_understanding integer,
  trainer_welcome integer

)
WITH (
  OIDS=FALSE
);
ALTER TABLE public.feedback2
  OWNER TO postgres;

HTML/PHP is



   <!DOCTYPE html>
<head>
<title>Enter Student Feedback</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
li {listt-style: none;}
</style>
</head>
<body>
<h2>Enter Student Feedback</h2>
<ul>
<form name="feedback" action="feedback.php" method="POST" >
<li>Date:</li><li><input type="date" name="date"></li>

<li>Location:</li>
        <li><select name="location"><option value=''></option><option value="1">UK</option><option value="2">NG</option><option value="3">SA</option><option value="4">KE</option><option value="5">Onsite</option></select></li>
<li>Course Name:</li>
        <li><select name="course"><option value=''></option><option value="1">INST-ZFS</option><option value="2">INST-RC</option><option value="3">ENG-ZFS</option><option value="4">ENG-RC</option><option value="5">NMS-OP</option><option value="6">NMS-ADM</option></select></li>
<li>Trainer:</li>
        <li><select name="trainer"><option value=''></option><option value="1">RSP</option><option value="2">DN</option><option value="3">ANO</option><option value="4">JO</option><option value="5">GN</option></select></li>
<li>Trainer Expertise:</li>
          <input type="radio" name="trainer_expertise" value="1">1<input type="radio" name="trainer_expertise" value="1">2<input type="radio" name="trainer_expertise" value="1">3<input type="radio" name="trainer_expertise" value="1">4<input type="radio" name="trainer_expertise" value="1">5<input type="radio" name="trainer_expertise" value="1">6
<li>Trainer Presentation:</li>
        <input type="radio" name="trainer_presentation" value="1">1<input type="radio" name="trainer_presentation" value="1">2<input type="radio" name="trainer_presentation" value="1">3<input type="radio" name="trainer_presentation" value="1">4<input type="radio" name="trainer_presentation" value="1">5<input type="radio" name="trainer_presentation" value="1">6
<li>Trainer Understanding:</li>
        <input type="radio" name="trainer_understanding" value="1">1<input type="radio" name="trainer_understanding" value="1">2<input type="radio" name="trainer_understanding" value="1">3<input type="radio" name="trainer_understanding" value="1">4<input type="radio" name="trainer_understanding" value="1">5<input type="radio" name="trainer_understanding" value="1">6
<li>Trainer Welcome:</li>
          <input type="radio" name="trainer_welcome" value="1">1<input type="radio" name="trainer_welcome" value="1">2<input type="radio" name="trainer_welcome" value="1">3<input type="radio" name="trainer_welcome" value="1">4<input type="radio" name="trainer_welcome" value="1">5<input type="radio" name="trainer_welcome" value="1">6
<li><input type="submit" /></li>
</form>
</ul>
</body>
</html>
<?php
$db = pg_connect("host=localhost port=5432 dbname=training user=postgres password=training");
$query = "INSERT INTO feedback2 VALUES ('$_POST[date]', '$_POST[location]', '$_POST[course]','$_POST[trainer]','$_POST[trainer_expertise]', '$_POST[trainer_presentation]', '$_POST[trainer_understanding]', '$_POST[trainer_welcome]')";
$result = pg_query($query);
?>

0 个答案:

没有答案