2013-08-22 3 views
0

J'ai un problème pour obtenir l'IPN de PayPal.IPN - ne fonctionne pas

Ceci est l'erreur du journal du serveur:

[22-Aug-2013 19:45:34 Asia/Jerusalem] PHP Warning: mysql_query() [function.mysql-query]: Access denied for user 'reshopco'@'localhost' (using password: NO) in /home/reshopco/public_html/8813/paypal3.php on line 61

[22-Aug-2013 19:45:34 Asia/Jerusalem] PHP Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/reshopco/public_html/8813/paypal3.php on line 61

Y at-il un problème avec le code ou peut-être un problème dans notre serveur?

Voici le code que je suis arrivé de l'exemple PayPal:

<? 
// read the post from PayPal system and add 'cmd' 
$req = 'cmd=_notify-validate'; 

foreach ($_POST as $key => $value) 
{ 
$value = urlencode(stripslashes($value)); 
$req .= "&$key=$value"; 
} 

// post back to PayPal system to validate 
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; 
$header .= "Host: www.paypal.com\r\n"; 
$header .= "Content-Type: application/x-www-form-urlencoded\r\n"; 
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; 
$header .= "Connection: close\r\n\r\n"; 

$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30); 


$payment_status = $_POST['payment_status']; 
$custom = $_POST["custom"]; 
$txn_type = $_POST["txn_type"]; 

// YOU CAN ALSO RETRIEVE ADDITIONAL FIELDS SUCH AS: 

// $payment_currency = $_POST['mc_currency']; 
// $txn_id = $_POST['txn_id']; 
// $receiver_email = $_POST['receiver_email']; 
// $payer_email = $_POST['payer_email']; 
// $invoice = $_POST['invoice']; 

// $firstName = $_POST["first_name"]; 
// $lastName = $_POST["last_name"]; 
// $street = $_POST["address_street"]; 
// $city = $_POST["address_city"]; 
// $pcode = $_POST["address_zip"]; 
// $county = $_POST["address_state"]; 
// $country = $_POST["address_country"]; 


if (!$fp) 
{ 
echo "HTTP ERROR"; 
} 
else 
{ // start 1 
fputs ($fp, $header . $req); 
while (!feof($fp)) 
{ // start 2 
$res = fgets ($fp, 1024); 
    if (strcmp ($res, "VERIFIED") == 0) 
    { // start 3 

// ONLY DO THE PROCESSING IF THE STATIS IS COMPLETED (REFUNDS ALSO HIT THE IPN) 
if ($payment_status == "Completed") 
{ // start 4 

// IF THE PAYMENT HAS BEEN MADE UPDATE OUR OIRDERS TABLE 
// WE PASSED OUR ORDER NUMBER TO PAYPAL IN THE custom FIELD AND USE THIS TO UPDATE THE CORRECT ORDER  
$sql = "Update orderstaable set processed = 0, paymentmethod = 'PAYPAL', orderdate = NOW() where orderid = $custom"; 
$execute = MYSQL_QUERY($sql); 

// SEND CUSTOMER EMAIL OR WHATEVER 
} // end 4 
    } // end 3 
    else if (strcmp ($res, "INVALID") == 1) 
    { // start 6 
    // log for manual investigation 
// email technical support 
    } // end 6 

} // end 2 
fclose ($fp); 
}// end 1 
?> 

Répondre

0

L'erreur que vous obtenez dans votre journal est parce que le combo utilisateur/mot de passe que vous utilisez pour vous connecter à votre base de données MySQL est incorrect.