mark103 Posted September 28, 2008 Share Posted September 28, 2008 Hi I have trouble by trying to visit paypal website with my php script. Parse error: syntax error, unexpected ':' in /home/www/mysite.com/test/paypal.php on line 2 This is the line 2 code: $url = ‘https://www.paypal.com/cgi-bin/webscr’; Do anyone knows what's wrong and why do I receive an error?? ??? ??? Thanks, Mark Quote Link to comment Share on other sites More sharing options...
dezkit Posted September 28, 2008 Share Posted September 28, 2008 $url = 'https://www.paypal.com/cgi-bin/webscr'; Quote Link to comment Share on other sites More sharing options...
mark103 Posted September 28, 2008 Author Share Posted September 28, 2008 Thanks for the help. Have another error: Parse error: syntax error, unexpected '=', expecting ')' in /home/www/mysite.com/test/paypal.php on line 4 This is line 4 code: foreach($_POST as $i => $v) { What's wrong, hopefully it can be fix. Thanks, Mark Quote Link to comment Share on other sites More sharing options...
dezkit Posted September 28, 2008 Share Posted September 28, 2008 foreach($_POST as $i => $v){ Quote Link to comment Share on other sites More sharing options...
mark103 Posted September 28, 2008 Author Share Posted September 28, 2008 Thanks, what about this one?? Parse error: syntax error, unexpected T_VARIABLE in /home/www/mysite.com/test/paypal.php on line 14 $web['port'] = 80; Quote Link to comment Share on other sites More sharing options...
dezkit Posted September 28, 2008 Share Posted September 28, 2008 let me see your line 13 Quote Link to comment Share on other sites More sharing options...
mark103 Posted September 28, 2008 Author Share Posted September 28, 2008 Here it is: $web['port'] = 80; Quote Link to comment Share on other sites More sharing options...
dezkit Posted September 28, 2008 Share Posted September 28, 2008 Line 13, not 14 Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted September 28, 2008 Share Posted September 28, 2008 Nothing wrong with that, there may be a syntax error before that line. Also Where have you got this script from? You obviously haven't coded it yourself. You may be better of posting the whole script here for use to review for you. Currently we seem to be going line by line fixing individual errors. I strongly suggest you also learn the basics of PHP too. Quote Link to comment Share on other sites More sharing options...
mark103 Posted September 28, 2008 Author Share Posted September 28, 2008 Oh sorry my mistake, here it is: if ($web['scheme'] == ‘https’) { $web['port'] = 443; $ssl = ’ssl//’; <<<<<<<<<<<< lines 13 $web['port'] = 80; Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted September 28, 2008 Share Posted September 28, 2008 @mark103 read my post above. Quote Link to comment Share on other sites More sharing options...
mark103 Posted September 28, 2008 Author Share Posted September 28, 2008 @dezkit: It said lines 14 that sysntax error where i get the trouble. Parse error: syntax error, unexpected T_VARIABLE in /home/www/mysite.com/test/paypal.php on line 14 if ($web['scheme'] == ‘https’) { $web['port'] = 443; $ssl = ’ssl//’; $web['port'] = 80; <<<<<<<<<<<< lines 14 I don't understand what the error means as they are not making any sense?? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted September 28, 2008 Share Posted September 28, 2008 Umm, did you read my post? I asked you to post your whole script here. Quote Link to comment Share on other sites More sharing options...
mark103 Posted September 28, 2008 Author Share Posted September 28, 2008 Ok here it is: <?php $url = 'https://www.paypal.com/cgi-bin/webscr'; $postdata = ”; foreach($_POST as $i => $v){ $postdata .= $i.‘’.urlencode($v).‘&’; $postdata .= ‘cmd_notify-validate’; $web = parse_url($url); if ($web['scheme'] == ‘https’) { $web['port'] = 443; $ssl = ’ssl//’; $web['port'] = 80; $ssl = ”; } $fp = @fsockopen($ssl.$web['host'], $web['port'], $errnum, $errstr, 30); if (! $fp) { echo $errnum.‘: ’.$errstr; } else { fputs($fp, “POST ”.$web['path'].“ HTTP/1.1rn”); fputs($fp, “Host: ”.$web['host'].“rn”); fputs($fp, “Content-type: application/x-www-form-urlencodedrn”); fputs($fp, “Content-length: ”.strlen($postdata).“rn”); fputs($fp, “Connection: closernrn”); fputs($fp, $postdata . “rnrn”); while(! feof($fp)) { $info[] = @fgets($fp, 1024); } fclose($fp); $info = implode(‘,’, $info); if (eregi(‘VERIFIED’, $info)) { // yes valid, f.e. change payment status } else { // invalid, log error or something } } ?> Umm, did you read my post? I asked you to post your whole script here. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted September 28, 2008 Share Posted September 28, 2008 I have fixed the syntax errors <?php $url = 'https://www.paypal.com/cgi-bin/webscr'; $postdata = ''; foreach($_POST as $i => $v) { $postdata .= $i.urlencode($v).'&'; $postdata .= 'cmd_notify-validate'; } $web = parse_url($url); if ($web['scheme'] == 'https') { $web['port'] = 443; $ssl = 'ssl//'; } else { $web['port'] = 80; $ssl = ''; } $fp = @fsockopen($ssl.$web['host'], $web['port'], $errnum, $errstr, 30); if (!$fp) { echo $errnum.': '.$errstr; } else { fputs($fp, "POST ".$web['path']." HTTP/1.1\r\n"); fputs($fp, "Host: ".$web['host']."\r\n"); fputs($fp, "Content-type: application/x-www-form-urlencodedrn"); fputs($fp, "Content-length: ".strlen($postdata)."\r\n"); fputs($fp, "Connection: closernrn"); fputs($fp, $postdata . "\r\n\r\n"); while(!feof($fp)) { $info[] = @fgets($fp, 1024); } fclose($fp); $info = implode(',', $info); if (eregi('VERIFIED', $info)) { // yes valid, f.e. change payment status } else { // invalid, log error or something } } ?> Quote Link to comment Share on other sites More sharing options...
mark103 Posted September 28, 2008 Author Share Posted September 28, 2008 Thanks for the help! But I can see the page is blank as I can see the text ':'. What's wrong, why I cannot connect to the site?? Please help! Thanks, Mark Quote Link to comment Share on other sites More sharing options...
dezkit Posted September 28, 2008 Share Posted September 28, 2008 oh sorry mark, i went afk on this page, as for the error, idk Quote Link to comment Share on other sites More sharing options...
mark103 Posted September 28, 2008 Author Share Posted September 28, 2008 @wildteen88: Do you know why I cannot connect to the site as the page goes blank. What's going on ??? ??? ??? Quote Link to comment Share on other sites More sharing options...
mark103 Posted September 28, 2008 Author Share Posted September 28, 2008 nobody?????????? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted September 29, 2008 Share Posted September 29, 2008 Can you explain whats the script is supposed to do? and what you're trying to do. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.