Page 1 of 1

Problem with curl

Posted: Wed Aug 27, 2008 5:41 pm
by cdunde1
I am trying to use this script and I am getting this error on the page "Parse error: parse error, unexpected T_GLOBAL in d:\websites\gatormaniacscom\test2.php on line 11" My host does have curl enabled and they think it's a coding error possible due to a missing colon or a space somewere? Any help would be appreciated. Here is the code

<? php
global $IPAddress,$_SERVER,$UserAgent,$PageURL,$URL;
$IPAddress = urlencode($_SERVER['REMOTE_ADDR']);
$UserAgent = urlencode($_SERVER['HTTP_USER_AGENT']);
$PageURL = urlencode($_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING ']);
$URL = "http://si.goldencan.com/GetData.aspx=1C ... 827381FF99;"
$URL = $URL.'&IPAddress='.$IPAddress;
$URL = $URL.'&UserAgent='.$UserAgent;
$URL = $URL.'&PageURL='.$PageURL;
readFile($URL);
$goldencanurl=$URL.'&PageURL='.$PageURL.'&IPAddress='.$IPAddress.'&UserAgent='.$UserAgent;

// create a new CURL resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "$goldencanurl");
curl_setopt($ch, CURLOPT_HEADER, false);
// grab URL and pass it to the browser
curl_exec($ch);
// close CURL resource, and free up system resources
curl_close($ch);
?>

Re: Problem with curl

Posted: Wed Aug 27, 2008 5:59 pm
by ghurtado
Are you sure this is the code for test2.php and that it produces the error you posted? Is there another page that includes this one?

The error is a syntax error and your code contains no syntax errors that I could see.

Re: Problem with curl

Posted: Wed Aug 27, 2008 8:47 pm
by cdunde1
Yes the gatormaniacs.com.test2.php is correct

Re: Problem with curl

Posted: Thu Aug 28, 2008 7:14 am
by ghurtado
Well, there's no syntax error on the code you posted line 11, so you are missing something.

Re: Problem with curl

Posted: Thu Aug 28, 2008 8:15 am
by susrisha
here is your error in this line.. semi colon not present..

Code: Select all

 
$URL = "http://si.goldencan.com/GetData.aspx=1C107227-3713-4D0E-8B16-C0827381FF99;"
 

Re: Problem with curl

Posted: Thu Aug 28, 2008 8:16 am
by susrisha
please let me know if i am correct..

Re: Problem with curl

Posted: Thu Aug 28, 2008 8:22 am
by ghurtado
Sounds like you are probably right, I kept looking at "line 11", duh!

Re: Problem with curl

Posted: Thu Aug 28, 2008 11:06 am
by cdunde1
Where should the semi colon be in that line of code?

Re: Problem with curl

Posted: Thu Aug 28, 2008 11:08 am
by ghurtado
8O

... at the end

Re: Problem with curl

Posted: Thu Aug 28, 2008 11:10 am
by cdunde1
I put the semi colon at the end of the line and i still get this error on the page

<b>Parse error</b>: parse error, unexpected T_GLOBAL in <b>d:\websites\gatormaniacscom\test2.php</b> on line <b>11</b><br />

I changed the code to this - $URL = "http://si.goldencan.com/GetData.aspx=1C ... 827381FF99";

Re: Problem with curl

Posted: Thu Aug 28, 2008 11:37 am
by ghurtado
Could there be another test2.php page that is getting picked up instead?

Re: Problem with curl

Posted: Thu Aug 28, 2008 12:29 pm
by cdunde1
Not sure if this will help. Below is the original code that I was trying to use on my web page. My host told me I cannot use the code because of the "include". I was then given the curl code that I posted in my earlier post. I was wondering if there was a different curl code that I could use to get this script to work? I appreciate all the help.

<?php
$SID="D74F59B9-C1B6-49F8-9734-97084DF29181";
$IPAddress = urlencode($_SERVER['REMOTE_ADDR']);
$UserAgent = urlencode($_SERVER['HTTP_USER_AGENT']);
$Host=urlencode($_SERVER['HTTP_HOST']);
$PageURL=urlencode($_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING']);
$URL="http://si.goldencan.com/GetData.aspx?ver=2.0&SID=".$SID;
$URL=$URL.'&Host='.$Host;
$URL = $URL.'&PageURL='.$PageURL;
$URL = $URL.'&IPAddress='.$IPAddress;
$URL = $URL.'&UserAgent='.$UserAgent;
include($URL);
?>

Re: Problem with curl

Posted: Thu Aug 28, 2008 12:51 pm
by ghurtado
Let me see if I got this straight because its gotten pretty confusing: the code you originally posted was not the code that was producing the error.

Then I asked you, specifically:
ghurtado wrote: Are you sure this is the code for test2.php and that it produces the error you posted? Is there another page that includes this one?
Yesterday you said "yes, I'm sure"

Now in your latest post you say "Not sure if this will help. Below is the original code that I was trying to use on my web page...."

Is this finally the code I have been asking for all along, the one that produces the original error you posted?

Re: Problem with curl

Posted: Thu Aug 28, 2008 2:44 pm
by cdunde1
Sorry for confusing you. Hopefully this will clear it up. I signed up with goldencan.com to have a product data feed displayed on my site. The code that I was given to display the data feed is this code -

<?php
$SID="D74F59B9-C1B6-49F8-9734-97084DF29181";
$IPAddress = urlencode($_SERVER['REMOTE_ADDR']);
$UserAgent = urlencode($_SERVER['HTTP_USER_AGENT']);
$Host=urlencode($_SERVER['HTTP_HOST']);
$PageURL=urlencode($_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING']);
$URL="http://si.goldencan.com/GetData.aspx?ver=2.0&SID=".$SID;
$URL=$URL.'&Host='.$Host;
$URL = $URL.'&PageURL='.$PageURL;
$URL = $URL.'&IPAddress='.$IPAddress;
$URL = $URL.'&UserAgent='.$UserAgent;
include($URL);
?>

This code has been placed on a web page currently at http://www.gatormaniacs.com/test1.php. That page displays a blank page. My host told me I cannot use the code because of the "include" in the code. They instructed me to use "Curl'. Goldencan.com gave me the following curl code which is curently on the web page at http://www.gatormaniacs.com/test2.php. That page gives the "Parse error: parse error, unexpected T_GLOBAL in d:\websites\gatormaniacscom\test2.php on line 11" error.

Curl Code - <?php global $IPAddress,$_SERVER;

$URL = "http://si.goldencan.com/GetData.aspx=1C ... 827381FF99";

$PageURL = urlencode($_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING']);

$IPAddress = urlencode($_SERVER['REMOTE_ADDR']);

$UserAgent = urlencode($_SERVER['HTTP_USER_AGENT']);

$goldencanurl=$URL.'&PageURL='.$PageURL.'&IPAddress='.$IPAddress.'&UserAgent='.$UserAgent;

// create a new CURL resource

$ch = curl_init();

// set URL and other appropriate options

curl_setopt($ch, CURLOPT_URL, "$goldencanurl");

curl_setopt($ch, CURLOPT_HEADER, false);

// grab URL and pass it to the browser

curl_exec($ch);

// close CURL resource, and free up system resources

curl_close($ch);

?>

My webhost has no idea why the curl code wont work and Goldencan.com has not been much help either.