Zipping Issue: Last File is not zipping

Objective of the blog:

The objective of this blog is to help you know how to fix the issue –“last file is not zipping”. If you are facing the same issue then this blog will help you. Example- If there are 4 text files then only 3 files are zipping.

Reason for this issue:

The zip_close($zip) function is not working due to which the file was unlinking before creating zip.

Solution:

You need to replace zip_close($zip) by $zip->close() to fix this issue.

Sample Code is given below:

$zip = new ZipArchive();
// zip 2 days older files
foreach (glob($directory. '/*.txt') as $a_file) {
if (filemtime($a_file) < time() - 172800) { //2 days older 172800
$filename_array = explode("/", $a_file);
$key = sizeof($filename_array) - 1;
$filename = $filename_array[$key];
$source_path = $directory.'/';
$zip_file = $source_path.str_replace('.txt','',$filename).".zip";
if ($zip->open($zip_file, ZipArchive::CREATE) !== TRUE) {
exit("cannot open".$zip_file."\n");
}
$zip->addFile($a_file,$filename);
}
}
$zip->close(); // Replaced zip_close($zip) by $zip->close();

// Move 90 days olders in the Archive and remove the files which are older than 180 days
foreach (glob($directory.'/*.zip') as $a_file) {
// remove files which older than 180 days.
if (filemtime($a_file) < time() - 15552000) { //180 days older 15552000
unlink($a_file);
}
}

Summary

In this blog, we have changed the zipping close function in order to fix the given issue.

MySQL Error: The user specified as a definer (‘xyz’@’localhost’) does not exist

The relational database management system MySQL is free and open-source. The word “My” is a combination of “SQL,” the acronym for a structured query language, and “My,” the name of co-founder Michael Widenius’s daughter.

A relational database arranges data into one or more tables where it is possible for the data to be related to one another. The relational database’s data can be created, modified, and extracted using the SQL programming language, which is also used to manage user access to the database. An RDBMS, such as MySQL, works with an operating system to implement a relational database in a computer’s storage system, manages users, permits network access, and makes it easier to test database integrity and create backups.

Under the terms of the GNU General Public License, MySQL is free and open-source software. It is also accessible under a number of proprietary licences. Sun Microsystems acquired the Swedish company MySQL AB, which owned and sponsored MySQL (now Oracle Corporation).

Objectives of the blog

To learn how to fix the issue “The user specified as a definer (‘xyz’@’localhost’) does not exist” in MySQL. It can be any value in place of ‘xyz’.

This error has occurred because you have defined different users in Definer and using other accounts in MySQL.

So while creating Triggers, you should use the “root@localhost” in the Definer. Follow the below steps to resolve this error:

Step 1: Open phpMyAdmin

Step 2: Select your database and table

Step 3: Click on the “Triggers” tab from the top of the page

Step 4: Click on the “Edit” to edit triggers.

Step 5: Change Definer from xyz@localhost to root@localhost

For more details check this screenshot:

You can contact us at support@knowband.com if you have any questions. Best-in-class solutions for all things eCommerce are offered by Knowband. Additionally, we offer custom development services for a variety of platforms like Prestashop, Opencart, Magento 2, and Magento 2.

Our Recommendation:

Our No Code eCommerce Mobile App Builder for Prestashop, Opencart, Woocommere, and Magento is a must-have for all eCommerce stores. Know more about it here: