Ecommerce Shopify WordPress Discussion

PHP – Unexpected character in input: '' (ASCII=20) state=0 [closed]

Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed yesterday. Improve this question I have come across this error for the first time and can't seem to debug it. My code which concerns this error is as follows: function save_contract( $post_id, $post, $update, $post_before ) { $post = get_post( $post_id ); $date_of_contract = get_field( 'date_of_contract', $post->ID ); //Class Theme Helper $template_file_name = require_once ( get_template_directory() . '/template.docx' ); $folder = require_once ( get_template_directory() . '/results_' ); $rand_no = rand(111111, 999999); $fileName = "results_" . $rand_no . ".docx"; $full_path = $folder . '/' . $fileName; try { if (!file_exists($folder)) { mkdir($folder); } //Copy the Template file to the Result Directory copy($template_file_name, $full_path); // add calss Zip Archive $zip_val = new ZipArchive; //Docx file is nothing but a zip file. Open this Zip File if($zip_val->open($full_path) == true) { // In the Open XML Wordprocessing format content is stored. // In the document.xml file located in the word directory. $key_file_name = 'word/document.xml'; $message = $zip_val->getFromName($key_file_name); $timestamp = date('d-M-Y H:i:s'); // this data Replace the placeholders with actual values $message = str_replace("date_of_contract", $date_of_contract, $message); //Replace the content with the new content created above. $zip_val->addFromString($key_file_name, $message); $zip_val->close(); } } catch (Exception $exc) { $error_message = "Error creating the Word Document"; var_dump($exc); } } add_action( 'wp_after_insert_post', 'save_contract', 10, 4 );
Here is some pieces of advice that you can take to fix this warning: 1- Check for file corruption Sometimes it's possible that it has become corrupted. Try replacing the file with a fresh copy from it's source. 2- Check for unexpected/non-standard characters Open the file "template.docx" and review lines 351 through 353 for any unexpected/non-standard characters. 3- Verify file encoding Most of times the file should be saved in UTF-8 encoding without a byte order mark (BOM). Open the target file and save it in the appropriate format. 4- Disable all other plugins and themes Temporarily disable all plugins and themes that may be causing conflicts. This can help identify if the warning is related to a specific plugin or theme. 5- Clear the cache Clear the cache of your WordPress site and browser. The cached files can sometimes cause unexpected issues. Let me know that if they could help.

January 12, 2024

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.