title: How do I use a user's input as 1 of the arguments for an sql function?
body: <p>*This is a simplified version of the code</p>
  
  <p>I have a query</p>
  
  <pre><code>SELECT func('123', x, '789');
  </code></pre>
  
  <p>where X is dependent on the user's input into a text box;</p>
  
  <p>I tried</p>
  
  <pre><code>$result = pg_query($conn, "SELECT func('123', _GET['x'], '789')");
  </code></pre>
  
  <p>where x is retrieved from</p>
  
  <pre><code>&lt;form method="get"&gt;
      x: &lt;input type="text" name="x"&gt;&lt;br/&gt;
      &lt;input type="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>however, this doesn't seem to work. Also, does the position of the PHP within the html make a difference?</p>
  
  <p>Here is the entire code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  &lt;?php
  
  $string_connection = "host=localhost port=5432 user=myname dbname=mydb";
  $conn = pg_connect($string_connection);
  
  $result = pg_query($conn, "SELECT get_champ('123', $_GET['x'], '789')");
  
  while ($row = pg_fetch_row($result)) {
      echo "$row[0]";
      echo "&lt;br/&gt;\n";
  }
  
  ?&gt;
  
  &lt;form method="get"&gt;
      End Date: &lt;input type="text" name="x"&gt;&lt;br/&gt;
      &lt;input type="submit"&gt;
  &lt;/form&gt;
  
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>