Friday, January 21, 2011

MySQL Warning - Out of range value for DATETIME column 'expire' at row 1

Problem:
While writing a web site I found I needed to update a field in a table with the current date plus 3 days.

Query:
UPDATE `user` SET `expire` = 'DATE_ADD(NOW() + INTERVAL 3 DAY)' WHERE `email` = '[email protected]';

mySQL Warning:
Warning 1264: Out of range value for column 'expire' at row 1

Solution:
After reading some I found that the solution was to remove the quotation marks around the DATE_ADD() method. It make sense since the method is run by mySQL and the quotation marks mean for mySQL to interpret this as a string.

Note: You can also remove the DATE_ADD method altogether, mySQL understands how to do the math by the addition sign.

Monday, December 13, 2010

Flash Debug Player In Google Chrome

After reading other blogs and pages online about this, I decided better instructions were needed.

Problem:
Getting Google Chrome to use the debug Flash Player wasn't working.

More Info:
Google Chrome began auto-updating the Flash plugin automatically since each update is generally a security patch of some sort.

Solution:
To get Flash Debug Player to work, do the following:

Download and install the Flash Debug Player for Netscape based browser (like FireFox and Chrome): http://www.adobe.com/support/flashplayer/downloads.html

Navigate to your chrome plugins page by entering the following url: about:plugins

Click the Details link in the top right corner. This will give you more information about each plugin.

Now you need to search for the Plugins related to Flash Player and disable the one located in the Chrome folder. (If your on Windows XP, it may have a path like this: C:\Documents and Settings\user_name\Local Settings\Application Data\Google\Chrome\Application\8.0.552.224\gcswf32.dll

Once you have disabled this, the other plugin (the debug player) should now be handling all your Flash Files.

Best of Luck

Wednesday, October 6, 2010

UnoException during conversion: URP_Bridge : disposed

Problem:

While trying to run unoconv, the process would be aborted and the following error would print out.

UnoException during conversion: URP_Bridge : disposed

Solution:
In my particular case, the server was running out of memory and therefore could not finish the process.

Hope this will help someone out who had the same problem.

Monday, August 30, 2010

Passing Shipping Info to Paypal Pro with API call doDirectPayment on OpenCart

Problem:
A client of mine wanted to use OpenCart for a shopping cart website and was using PayPal pro to handle the e-commerce. The problem was that the only information OpenCart passed to PayPal was the information needed to process the credit card. This makes sense if you are handling all your shipping things in OpenCart, however in my clients situation, they needed someone else on PayPal to be able to see the shipping information for fulfilling the orders.

Solution:
The PHP file handling the connection to PalPay was only passing some of the data, not all of it. If you look at the file: root/catalog/controller/payment/pp_pro.php, you will see a PHP associative array handling all the data that will be passed to PayPal. (Note: an associative array is where you can hold a lot of data in one container and by using what are called key/value pairs. For instance a key might be something like shoe_size and the value may be something like 12 written in PHP with key => value). I looked into the object holding on the user data and found that just like payment_*** you can use shipping_***. So my setup ended up looking similar to this:

$payment_data = array(
            'METHOD'         => 'DoDirectPayment',
            'VERSION'        => '51.0',
            'USER'           => html_entity_decode($this->config->get('pp_pro_username'), ENT_QUOTES, 'UTF-8'),
            'PWD'            => html_entity_decode($this->config->get('pp_pro_password'), ENT_QUOTES, 'UTF-8'),
            'SIGNATURE'      => html_entity_decode($this->config->get('pp_pro_signature'), ENT_QUOTES, 'UTF-8'),
            'CUSTREF'        => $order_info['order_id'],
            'PAYMENTACTION'  => $payment_type,
            'AMT'            => $this->currency->format($order_info['total'], $order_info['currency'], $order_info['value'], FALSE),
            'CREDITCARDTYPE' => $this->request->post['cc_type'],
            'ACCT'           => str_replace(' ', '', $this->request->post['cc_number']),
            'CARDSTART'      => $this->request->post['cc_start_date_month'] . $this->request->post['cc_start_date_year'],
            'EXPDATE'        => $this->request->post['cc_expire_date_month'] . $this->request->post['cc_expire_date_year'],
            'CVV2'           => $this->request->post['cc_cvv2'],
            'CARDISSUE'      => $this->request->post['cc_issue'],
            'FIRSTNAME'      => $order_info['payment_firstname'],
            'LASTNAME'       => $order_info['payment_lastname'],
            'EMAIL'          => $order_info['email'],
            'PHONENUM'       => $order_info['telephone'],
            'IPADDRESS'      => $this->request->server['REMOTE_ADDR'],
            'STREET'         => $order_info['payment_address_1'],
            'CITY'           => $order_info['payment_city'],
            'STATE'          => ($order_info['payment_iso_code_2'] != 'US') ? $order_info['payment_zone'] : $order_info['payment_zone_code'],
            'ZIP'            => $order_info['payment_postcode'],
            'COUNTRYCODE'    => $order_info['payment_iso_code_2'],
            'CURRENCYCODE'   => $order_info['currency'],
            'DESC'            => 'items being ordered - 127 char limit',
            'SHIPTONAME'     => $order_info['shipping_firstname'] . $order_info['shipping_lastname'],
            'SHIPTOSTREET'     => $order_info['shipping_address_1'],
            'SHIPTOCITY'     => $order_info['shipping_city'],
            'SHIPTOSTATE'     => ($order_info['shipping_iso_code_2'] != 'US') ? $order_info['shipping_zone'] : $order_info['shipping_zone_code'],
            'SHIPTOZIP'         => $order_info['shipping_postcode'],
            'SHIPTOCOUNTRY'     => $order_info['shipping_iso_code_2'],
            'SHIPTOPHONENUM' => $order_info['telephone']
);
Hopefully this will help out some who have had issues with this.

Wednesday, August 25, 2010

Symfony 1.4 - crashing when loading large fixture files

Problem:
I have been trying to load a large fixture file in Symfony but everytime I went to load the fixture using doctrine:load-data, Symfony would crash. I looked at the mySQL tables and found that Symfony had in fact finished loading the fixture, but for some reason had become non-responsive.

Solution:
To allow symfony to load the fixture (whether it crashes due to system resources like PHP memory or an issue with PHP itself), I found that I can control the loading of the fixture by following these simple steps.

  1. Split the fixture into several files (While keeping your table reference in each one)
  2. Load each fixture file 1 at a time (this can be accomplished using doctrine:data-load --append rel/path/to/fixture)
  3. check your tables to ensure data is still being loaded, if you find it has stalled more a good amount of time and nothing has been loaded, you will probably want to look into killing the PHP process (something I wont explain here) and doing some more fixture break downs.
Hopefully this will help some of you who have had the same issue I have been having.

Tuesday, August 24, 2010

Control Loading Order / Sequence of Fixtures in Symfony 1.4

Problem:

I want to split my fixtures into separate files in the fixtures directory but when I try to load the data, I get constraint errors.

Solution:
Symfony has a solution for determining the sequence it should use to load fixtures, that is by placing a number in from of the original file name. I use 1_filename.yml.

Good luck programming.

Friday, August 20, 2010

Apply Smoothing to Video in Spark VideoPlayer or VideoDisplay Component

Problem:
I want to allow smoothing on the video that is being played by a Spark VideoPlayer or VideoDisplay component but those components don't have a property for this.

Solution:
To smooth a video being played by one of these components, you have to access the video object once it is loaded. These components do not provide a smoothing option directly. To determine when a video has loaded, we will detect a state change on the component itself by adding a MediaPlayerStateChangeEvent listener.

MXML:
<s:VideoDisplay id="vid_player" top="0" left="0" right="0" bottom="0" source="video.flv"  mediaPlayerStateChange="checkState(event)" />

AS3 (MXML Alternative) - attach the listener with AS3:
vid_player.addEventListener(MediaPlayerStateChangeEvent.MEDIA_PLAYER_STATE_CHANGE, checkState)

The checkState method will do more to check is the video has successfully loaded.

AS3 - checkState Method:
import org.osmf.events.MediaPlayerStateChangeEvent;
private function checkState(e:MediaPlayerStateChangeEvent):void{
    if(e.state == "playing") 
        vid_player.videoObject.smoothing = true;
}

 If you try to access the videoObject before the "playing" state, you will get a null reference.

Please let me know if you come across any questions with this code.