title: Inser checkbox inputs into a postgresql with php
body: <p>I'm trying to introduce the value of a checkbox into my database in postgresql. I created the table account with a colum named: getrequest which is the type boolean. </p>
  
  <p>I'm using the code below, but I'm getting the following error:</p>
  
  <p>Error with query: ERROR: invalid input syntax for type boolean: "" LINE 1: ...account(getrequest) VALUES('', ... ^ </p>
  
  <p>Any help would be highly appreciated.</p>
  
  <p>Thanks</p>
  
  <pre><code>&lt;?php
  
  $getrequest  =  "";
  
      $db = pg_connect('host=localhost dbname=test user=myuser password=mypass');
  
      $getrequest = pg_escape_string($_POST['getrequest']);
  
      $query = "INSERT INTO account(getrequest) VALUES('" . $getrequest . "')";
  
               $result = pg_query($db, $query);
          if (!$result) {
             $errormessage = pg_last_error();
                 echo "Error with query: " . $errormessage;
             exit();
            }
  
              $getrequest =  "";
  
       pg_close();
  
  
  function test_input($data) {
   $data = trim($data);
   $data = stripslashes($data);
   $data = htmlspecialchars($data);
   return $data;
  }
  
  ?&gt;
  &lt;form method="post" action="&lt;?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?&gt;"&gt;
  
  &lt;input type="checkbox" name="getrequest" value="getrequest" class="regular-checkbox"&gt;I get a request&lt;br&gt; 
  
  &lt;br&gt;
  
  &lt;input type="submit" name="submit" value="SAVE"&gt;
  &lt;/form&gt;
  </code></pre>