title: How to use CURL via a proxy?
body: <p>I am looking to set curl to use a proxy server. The url is provided by an html form, which has not been a problem. Without the proxy it works fine. I have found code on this and other sites, but they do not work. Any help in finding the correct solution would be much appreciated. I feel that the bellow are close, but that I am missing something. Thank You.</p>
  
  <p>The bellow code I adapted from here <a href="http://www.webmasterworld.com/forum88/10572.htm" rel="noreferrer">http://www.webmasterworld.com/forum88/10572.htm</a> but it returns an error message about a missing T_VARIABLE on line 12.</p>
  
  <pre><code>&lt;?
  
  $url = '$_POST[1]';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,$url);
  curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 0);
  curl_setopt($ch, CURLOPT_PROXY, '66.96.200.39:80');
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST,'GET');
  curl_setopt ($ch, CURLOPT_HEADER, 1)
  curl_exec ($ch); 
  $curl_info = curl_getinfo($ch);
  curl_close($ch);
  echo '&lt;br /&gt;';
  print_r($curl_info);
  ?&gt;
  </code></pre>
  
  <p>The bellow is from <a href="https://stackoverflow.com/questions/4802816/curl-through-proxy-returns-no-content">curl through proxy returns no content</a></p>
  
  <pre><code>&lt;?
  
  $proxy = "66.96.200.39:80";
  $proxy = explode(':', $proxy);
  $url = "$_POST[1]";
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_PROXY, $proxy[0]);
  curl_setopt($ch, CURLOPT_PROXYPORT, $proxy[1]);
  curl_setopt($ch, CURLOPT_HEADER, 1);
  
  $exec = curl_exec($ch);
  
  echo curl_error($ch);
  print_r(curl_getinfo($ch));
  echo $exec;
  ?&gt;
  </code></pre>
  
  <p>is currently live on pelican-cement.com but also does not work.</p>
  
  <p>UPDATE:
  Thank you for all your help, I made the above changes. Now it only returns a blank screen.</p>
  
  <pre><code>&lt;?
  
  $url = $_POST['1'];
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,$url);
  curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 0);
  curl_setopt($ch, CURLOPT_PROXY, '66.96.200.39:80');
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST,'GET');
  curl_setopt ($ch, CURLOPT_HEADER, 1);
  curl_exec ($ch); 
  $curl_scraped_page = curl_exec($ch);
  curl_close($ch);
  
  echo $curl_scraped_page;
  ?&gt; 
  </code></pre>