title: Warning: pg_query() [function.pg-query]: Query failed: ERROR: unterminated quoted string at or near
body: <p>I have a query where I get the error:</p>
  
  <p>The code is:</p>
  
  <pre><code>$prefix = $data-&gt;sheets[0]['cells'][$row][2];
  $fiyat = $data-&gt;sheets[0]['cells'][$row][3];
  $increment = $data-&gt;sheets[0]['cells'][$row][4];
  $tarih = $data-&gt;sheets[0]['cells'][$row][5];
  $tarih = explode('.',$tarih);
  $effective_date = $tarih[2] . "-" . $tarih[1] . "-" . $tarih[0];
  </code></pre>
  
  <p>All variables returns correct values (and variable types).</p>
  
  <pre><code>$query_insert_to_rates = "INSERT INTO rates VALUES (nextval('routes_seq'), '$prefix', '$i_tariff', '$fiyat_orj', '$fiyat_orj', '$increment', '$increment', '$forbidden', 't', '0', '0', '$increment', '$increment', NULL, '$eff_date_ins', NULL);";
  </code></pre>
  
  <p>$result_insert_to_rates = pg_query($query_insert_to_rates);</p>
  
  <pre><code>INSERT INTO rates VALUES (nextval('routes_seq'), '21321', '8', '0.0470', '0.0470', '1', '1', 't', 't', '0', '0', '1', '1', NULL, '2012-06-01 00:00:00.000001+02', NULL);
  </code></pre>
  
  <blockquote>
    <p>Warning: pg_query() [function.pg-query]: Query failed: ERROR: unterminated quoted string at or near "'2" at character 50 in.....</p>
  </blockquote>
  
  <p>Now, when I run the query within the PHP, I get the above error. My PHP Version is 5.3.10. And the machine is Centos 5 (VPS). </p>
  
  <p>However if I run the query through Navicat(connected to the DB) then I have no error, and query executed perfectly.</p>
  
  <p>Any help would be appreciated.</p>