Skip to Main Content

The One Three Web Design Blog

PGSQL Driver Mismatch

May 13, 2011

PDO: driver pgsql requires PDO API version 20060409; this is PDO version 20060511

The above error was the final roadblock in getting one of our servers back into working condition after a server upgrade. I am posting this here because it took a very long time to discover a solution and I found the solution on a site in German. Thank you google translate.

In short, this server is a combination of PHP, Lighttpd and PGSQL. After the update Apache tried to run at startup and I had to remove the links to the Apache startup scripts found in /etc/rc*.d. A few more step to clear a Lighttpd warning about ipv6 and then I tried to start Lighttpd, /etc/init.d/lighttpd start. That’s when the above error reared its ugly head.

Some generic searches gave some results, but nothing that said “do this to fix it”. Until I slapped the error in google word for word and found a handful of Chinese and German pages talking about it. Fixing this issue ultimately required upgrading PDO and its PGSQL module and that looked something like this:

  1. pecl uninstall pdo pdo_pgsql
  2. pear upgrade PEAR
  3. pecl install pdo pdo_pgsql

Start Lighttpd and life was back to normal!

Getting Started

This PDF File is a great place to start.

It will show you how to set up IPN notifications, what to expect from paypal, the process to verify the notification and even gives you some sample code.

IPN, while not required, is a great way to know when you’ve actually gotten paid. This way you don not have to sift through the mountains of emails of profile creation, payment reversed, payment canceled, payment completed, etc. Getting the IPN that says Complete lets you know to make a shipment because you’ve actually gotten paid. At least in theory.

Example Code

The example code provided by Paypal is written in PHP and is a good starting place.

I’m repeating it below, for the most part, with my modifications to ignore IPN notifications I don’t care about and to use CURL instead of fgets

Testing

There are two ways to test before pushing up to production which ultimately leads to the problem. You can force an IPN to be sent to you through the sandbox with 100% test data or actually do a test purchase.

Following the code provided leads to the issue. The forced test IPN works quite nicely; you get it, send it back and Paypal says VERIFIED every single time. Doing a test transaction however returns INVALID without fail.

I found the solution on this site. The long and short is there is a carriage return between address line 1 and line 2 that paypal represents as %0D%0A but is represented as %0A in PHP 5.2.

So below is what I hope is simplified code, assumes you have magic quotes turned on, uses curl and has the carriage return fix:

  1. <?php
  2. $PAYPAL_URL = “https://www.sandbox.paypal.com”; //or https://www.paypal.com
  3. $PAYPAL_EMAIL = “your_email@gmail.com”; //usually your login email
  4.  
  5. if($_POST['txn_id'] && $_POST['receiver_email'] == $PAYPAL_EMAIL){
  6. //Check for Primary PayPal email, also ignores profile creation IPNs, just care about payments for now
  7.  
  8. $url = “$PAYPAL_URL/cgi-bin/webscr”;
  9. $http_status = 0;
  10. $params = “cmd=_notify-validate”;
  11.  
  12. foreach ($_POST as $key => $value){
  13. $value = urlencode(stripslashes($value));
  14. $value = preg_replace(‘/(.*[^%^0^D])(%0A)(.*)/i’,'${1}%0D%0A${3}’,$value);//return fix
  15. $params .= “&$key=$value”;
  16. }
  17.  
  18. $response = http($url, $http_status, $params);
  19. if($response == “VERIFIED” && $http_status == 200){
  20. //Check that txn_id has not been previously processed
  21. //Process the IPN recieved based on the payment_status
  22. }
  23. else{
  24. //store for further investigation or ignore
  25. }
  26. }
  27.  
  28. function http($url, &$http_status, $post_data){
  29. $ch = curl_init();
  30. if (defined(“CURL_CA_BUNDLE_PATH”)) curl_setopt($ch, CURLOPT_CAINFO, CURL_CA_BUNDLE_PATH);
  31. curl_setopt($ch, CURLOPT_URL, $url);
  32. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
  33. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  34. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  35.  
  36. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  37. if (isset($post_data)){
  38. curl_setopt($ch, CURLOPT_POST, 1);
  39. curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
  40. }
  41. $r = curl_exec($ch);
  42. $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  43.  
  44. curl_close ($ch);
  45. return $r;
  46. }
  47. ?>

As I prepare to re-build my portfolio, I’ve been spending a lot of time just getting caught up on everything I’ve missed over the past year and a half. OK, well I haven’t been completely out of the loop, it just feels that way.

But as I go through my portfolio I’m treating it as a project. Starting out with content, building a site map and letting that lead to design.

The most frustrating part of the HTML5s is reading about built in form validation, easy video/audio and semantic tags that describe their content is the variations in browser support. So I’ve come up with a short list of things you can do now, that work across all browsers and don’t require JavaScript help.

Doctypes

Everyone’s seen this:

  1. <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>

It’s excessively long and hard to memorize, and I have a 25 character Windows XP code committed to memory. Wouldn’t it be great to get rid of it? Well here is the HTML5 doctype, and you can start using it today:

  1. <!DOCTYPE html>

Charset

Not really revolutionary, but somewhat space saving, the meta charset declaration can be reduced from:

  1. <meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />

To:

  1. <meta charset=”UTF-8″ />

Other Space Savers

Script tags can be reduced to:

  1. <script src=”file.js”></script>

And those bad in-line styles can be wrapped in:

  1. <style>display: block;</style>

What Else?

Well sadly, nothing, without consideration for certain browsers that shall remain nameless. You can start to use HTML5 tags for some really semantic markup, but styling them can be problematic as some older, very widely used, browsers have no idea what you are talking about. You can use the HTML5 Shiv, but then you are requiring JavaScript.

Video tags are a great way to avoid having to pay for a quality flash player. But, if your browser supports the video tag, there is no guarantee it will support your format. You can convert your file to another format, but that’s making life hard again.

One day we can put all this talk behind us. It’s both scary and exciting to think that IE9 beta was released just last week. IE9 has implemented a ton of HTML5 features and done some crazy canvas optimizations. Yet IE6 still refuses to die and supporting 4 versions of IE is not very exciting news.

Peering Into the Future

Jan 21, 2010

Back at it again. I’ve been building, creating, trying and writing; and it’s time to share a bit of what I’ve learned.

Future Blog Posts

oAuth

I started to read about the process of using oAuth to authenticate with Twitter. There are several libraries out there already written, but I wanted to try to write my own. So, I developed what I am calling twitAuth in php and used it to create the site talkietweets.com (Re-design and expansions in the works). I’m working on a several part write up on how to create your own.

jQuery 1.4

The biggest and fastest version of jQuery has just been released and I’ve had a bit of time to play with it. So, given that I’m teaching a course on Javascript and jQuery at work it’s time to return to my favorite library and perhaps finish some plugins.

Raphael

After reading a bit about Google’s Closure library i ran into an article on why Closure is terrible. That lead me to the library Raphael and particularly the tiger drawing in the demos. I decided to combine Raphael and jQuery to create art tools and I’m currently working on a pen tool much like you would find in PhotoShop.

Site Stuff

Even though I still like my site, a few pages could definitely use some work. The about us, contact and portfolio pages to be exact. When I first created the portfolio page I made the images huge to compinsate for lack of sites. Having launched 24 sites with FIRSTROI its time to dial it back a bit and re-think some things.

Good things to come and hopefully more frequent posts. Hopefully.

Overdue Update

Oct 13, 2009

How do you know when you are overworked?

Oh I don’t know, maybe its when you can’t come up for air long enough to see your friends, take care of your house, sleep or even open up google reader to keep up with current trends and best practices.

And its not due to overextending myself, it’s just my primary job. You know, that thing that puts food on the table. But nlately, I’ve been working to get things under control.

I’ve even had time to work on a few freelance projects and started work on a couple personal projects I’ve been mulling over for a year now.

So what?

I’ve decided to no longer be just a passenger in the web game.

I’ve been discovering a lot about my favorite JavaScript library jQuery. I’m rediscovering my love for object oriented programming with PHP. And I’m thoroughly enjoying working with friends and co-workers to produce some very nice sites outside of work, and i plan to take all of this and write about it to share with the interwebs so that my trials and tribulations do not have to be repeated by others. And keep an eye out for a few jQuery plugins along the way.