Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6679761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:23:46+00:00 2026-05-26T04:23:46+00:00

So i recently created PayPal IPN script, but while I was testing it with

  • 0

So i recently created PayPal IPN script, but while I was testing it with Sandbox (test) accounts, I saw problem, everything was excellent, except it just didn’t insert any data in database, well verified part just didn’t work, neather did INVALID part, didn’t work.
You can take a look on my script here –

<?php
// PHP 4.1

// 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 .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];

if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
  if($receiver_email == 'test_1318600337_biz@gmail.com')
  {
      include('../database.php');
      $result = mysql_query("SELECT * FROM `smscodes` WHERE code = '$item_number';");
      $select_id = mysql_fetch_array($result);
      mysql_query('UPDATE `advertisements` SET status="accepted" WHERE id = "'.$select_id['adv-id'].'"');
      mysql_query("DELETE FROM `smscodes` WHERE `code` = '".$item_number."' LIMIT 1");
  }
}
else if (strcmp ($res, "INVALID") == 0) {
$to = 'myemailishere@myemailishere.com';
 mail($to, "Error, something is wrong with paypal script", "Error, something is wrong with paypal script");
}
}
fclose ($fp);
}
?>

And my button is –

  <form name="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr" 
      method="post">
      <input type="hidden" name="cmd" value="_xclick">
      <input type="hidden" name="business" value="test_1318600337_biz@gmail.com">
      <input type="hidden" name="currency_code" value="EUR">
      <input type="hidden" name="item_name" value="Add Advertisement">
      <input type="hidden" name="amount" value="3.00">
      <input type="hidden" name="item_number" value="<?php echo $_SESSION['code']; ?>">
      <input type="hidden" name="return" value="http://site.com">
      <input type="hidden" name="notify_url" value="mysite.com/tsatstastast/ipn.php">
      <input type="image" src="http://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif" 
          border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
  </form>

In PayPal IPN history it shows succeed with HTTP 200, but I don’t have any clues why it doesn’t insert anything inside database. database.php file is okay, and it got all information of database inside. Hope you can help me with this problem.
EDIT: Forgot to mention, with PayPal Test tool, where you insert IPN script code, and it verifies if it is working, everything worked great. But with button, and test account it doesn’t. Oh and smscodes table, it’s correct, I’m using same table for paypal and sms payments, so no worries about it ;)!
EDIT: Tried to change to ssl://www.sandbox.paypal.com but without chance, now ill try to debug it .
EDIT 3: So I just found the error, it was In paypal sandbox account setting, didn’t turn on notificy messages. Now i got one message that says mail($to, “Error, something is wrong with paypal script”, “Error, something is wrong with paypal script”); , so it failed. What to do, any help would be appreciated!
Best regards,
Valters

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:23:46+00:00Added an answer on May 26, 2026 at 4:23 am

    Try debugging it with the values fsockopen() provides:

    $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
    if (!$fp)
    {
        echo $errstr . ' (' . $errno . ')';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently created my first bash script, and I am having problems perfecting it's
Recently created a MVC2 Portal but now I want to add a couple of
I have recently created an API on my server in PHP, but I have
I have a little problem. I've recently created an algorithm to allow thick lines
I have recently created an upload function, but I don't know how to change
I recently created a advanced form with elements that use jquery's $().hide & $().show
I recently created my simple log4net database table for logging via the adonet appender..
I recently created a class which has a constructor taking 3 enumerations as arguments.
I recently created a generic Matrix<T> class that acts as a wrapper around a
I recently created a function in javascript that takes in a file name and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.