Jump to content

[SOLVED] syntax error


mark103

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

@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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.