title: How to escape a single quote
body: <p>I'm using the <code>pg_query_params</code> function to add values in my table <code>vmobjects</code> in my <code>addvm.php</code> page.</p>
  
  <pre><code>$query = "INSERT INTO vmobjects(guid, ipaddress, username, password, hostid, vmname, guestostype) VALUES($1, $2, $3, $4, $5, $6,
  
  $7)";
          $result = pg_query_params($conn, $query, array($guid, $ip, $username, $password, $hostid, $name, strtolower($os)));
  </code></pre>
  
  <p>Now I'm using <code>pg_fetch_array</code> for fetch the row in an array.</p>
  
  <p>I'm using this query:</p>
  
  <pre><code>$query = "select vmname, guid, hostid, guestosname from vmobjects";
  
  AddLog("infrastructure.php", "Query: ".$query, ERR_DEBUG_LOW);
  $result = pg_query($conn, $query);
  $no_records = pg_num_rows($result);
  $j = $no_records;
  $i = 0;
  while($row = pg_fetch_array($result))
  {
      if($row[3] == "")
      {
          $vmobj_Array[$i] = $row[0] . '***' . $row[1] . '***' . $row[2];
      }
      else
      {
          $vmobj_Array[$i] = $row[0] . ' ( ' . $row[3] . ' )' . '***' . $row[1] . '***' . $row[2];
      }
      $i++;
  }
  </code></pre>
  
  <p>But it is working only for a simple string like <code>james, helton, discovere</code>, not for <code>j'ames, h'elton, d'iscovere</code>.</p>
  
  <p>Actually I want to fetch the row in <em>both</em> formats.</p>