Tag Archives: PHP

Cardsave error “transaction date/time expired”

If you are using CardSave (UK Version) and you come across the following error:

This transaction cannot be processed. It was rejected because the passed transaction date/time has expired. Please press “Back” in your browser and resubmit the transaction.”

It’s caused by your server providing a different timezone to your CardSave Gateway. You need to setup your server/script time zone to UTC.  In PHP you can do this by simply adding this line to your script:  date_default_timezone_set(‘UTC’);

For example, I was having a problem with the Cardsave(hosted) payment extension for OpenCart.  If you are having the same problem do this:

  1. Open the file /catalog/controler/payment/cardsave_hosted.php
  2. Find this line  $this->data['fields']['TransactionDateTime'] = (date(“Y-m-d H:i:s”).  ‘ +00:00′);  (line 305 I think)
  3. Just before that line add this :  date_default_timezone_set(‘UTC’); 
  4. Upload file to server and you are sorted.

Technorati Tags: , , , , , ,

It is not safe to rely on the system’s timezone settings

Recently I have been having the following error on my PHP code every time I call the PHP function date();  Mostly when running it on my local test server.

Warning: date(): It is not safe to rely on the system’s timezone settings

Cause: Since PHP5.1.0 the E_RESTRICT setting causes PHP to report error for every call
to a date/time function, if no default time is set.

Fix:
There are 2 approaches to  resolving this.

  1. Set time setting to your PHP script with the function date_default_timezone_set();  with the intended time zone/location eg: for GMT one can use date_default_timezone_set(‘Europe/London’);
  2. Set time setting to your php.ini file by editing the line ;date.timezone = to date.timezone = “Europe/London” or you required location. This is good for setting a server wide time setting.

Technorati Tags: , , , , ,

Automatically display form data with PHP

This is a simple PHP  script to automatically display (dump output)  data submited from a html form.

The form setup

  • all inputs (form fields) need to have the same name with [] at the end to turn it into an array,  e.g <input type=text name=formdata[]>

formq.html content

<form method=post action=showme.php>
Name: <input type=text name=formdata[]><br>
Email: <input type=text name=formdata[]><br>

<input type=submit value=ok>
</form>

The Script setup

showme.php content

<?php
$data = $_POST['formdata']; # get value from the form fields

foreach ( $data as $key => $value ) { # loop through array collecting the results

echo  “$value<br>”;  # output the data  – print to page
}
?>

Technorati Tags: , , , ,

PDF to Email with registration

Serve PDF files on your website by requesting the user to register their email address. The PDF file is sent to the given email address and the user details registered on a database. This is a very simple script and relies on four main features.

Apache mod_rewrite (via the .htaccess file)

PHPMailer

MySQL database

the simple-register.php script itself

Read more »

Technorati Tags: , , ,

SugarCRM Installation error: session.save_path not set

SugarCRM Community Edition 5.2.0a has shown me the following error during installation.

“The session.save_path setting in your php configuration file (php.ini)
is not set or is set to a folder which did not exist. You might need to
set the save_path setting in php.ini or verify that the folder sets in
save_path exist.”

Before you attempt to follow my instructions here, please check that the session.save_path in your php.ini is properly set and that your webserver is behaving normally.

This error is apparently a bug in the installation process of SugarCRM so to get past it you need to edit a PHP file.

  1. Open the file SystemCheck.php (it is located in the install folder)
  2. uncomment lines 184 to 210  (just place /* on line 183   and  */ on line 211)
  3. save file and restart installation

Technorati Tags: , ,