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 Link to comment https://forums.phpfreaks.com/topic/126164-solved-syntax-error/ 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'; Link to comment https://forums.phpfreaks.com/topic/126164-solved-syntax-error/#findComment-652385 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 Link to comment https://forums.phpfreaks.com/topic/126164-solved-syntax-error/#findComment-652389 Share on other sites More sharing options...
dezkit Posted September 28, 2008 Share Posted September 28, 2008 foreach($_POST as $i => $v){ Link to comment https://forums.phpfreaks.com/topic/126164-solved-syntax-error/#findComment-652394 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; Link to comment https://forums.phpfreaks.com/topic/126164-solved-syntax-error/#findComment-652395 Share on other sites More sharing options...
dezkit Posted September 28, 2008 Share Posted September 28, 2008 let me see your line 13 Link to comment https://forums.phpfreaks.com/topic/126164-solved-syntax-error/#findComment-652398 Share on other sites More sharing options...
mark103 Posted September 28, 2008 Author Share Posted September 28, 2008 Here it is: $web['port'] = 80; Link to comment https://forums.phpfreaks.com/topic/126164-solved-syntax-error/#findComment-652399 Share on other sites More sharing options...
dezkit Posted September 28, 2008 Share Posted September 28, 2008 Line 13, not 14 Link to comment https://forums.phpfreaks.com/topic/126164-solved-syntax-error/#findComment-652401 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. Link to comment https://forums.phpfreaks.com/topic/126164-solved-syntax-error/#findComment-652402 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; Link to comment https://forums.phpfreaks.com/topic/126164-solved-syntax-error/#findComment-652403 Share on other sites More sharing options...
wildteen88 Posted September 28, 2008 Share Posted September 28, 2008 @mark103 read my post above. Link to comment https://forums.phpfreaks.com/topic/126164-solved-syntax-error/#findComment-652406 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?? Link to comment https://forums.phpfreaks.com/topic/126164-solved-syntax-error/#findComment-652407 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. Link to comment https://forums.phpfreaks.com/topic/126164-solved-syntax-error/#findComment-652409 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. Link to comment https://forums.phpfreaks.com/topic/126164-solved-syntax-error/#findComment-652411 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 } } ?> Link to comment https://forums.phpfreaks.com/topic/126164-solved-syntax-error/#findComment-652414 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 Link to comment https://forums.phpfreaks.com/topic/126164-solved-syntax-error/#findComment-652416 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 Link to comment https://forums.phpfreaks.com/topic/126164-solved-syntax-error/#findComment-652421 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 ??? ??? ??? Link to comment https://forums.phpfreaks.com/topic/126164-solved-syntax-error/#findComment-652422 Share on other sites More sharing options...
mark103 Posted September 28, 2008 Author Share Posted September 28, 2008 nobody?????????? Link to comment https://forums.phpfreaks.com/topic/126164-solved-syntax-error/#findComment-652540 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. Link to comment https://forums.phpfreaks.com/topic/126164-solved-syntax-error/#findComment-653176 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.