How do I find files that may have extra line breaks or whitespace after the ?> in a PHP file?
Created: Aug 28, 2009 12:20 AM
Last Modified: Aug 17, 2011 11:15 AM
1
Rating
|
When a PHP script has extra whitespace after the final ?> a headers errors can result. In the normal operation of your X-Cart store this can cause a message to display when adding products to the cart, or clicking links on your store:
If the page is not updated in 2 seconds, please follow this link.
When using modules such as the One Page Checkout that transfer XML data between the browser and the server this whitespace can cause the application to fail. To fix this:
1. Download this script: find_whitespace.zip (1.16 KB)
2. Unzip the find_whitespace.php file and upload it to the root of your X-Cart store.
3. Open this script in a web browser. Example: http://www.yourstore.com/find_whitespace.php
The page will display all files in your X-Cart directory that have extra space after the final ?>

You will need to open these files in a text editor and remove the whitespace. Then re-upload the file to your website.
File with extra whitespace:

Removed:

If your FTP client adds the whitespace again after removing it you will need to upload the file in binary mode (see your FTP client help to change your upload settings). This can be caused by having both Windows \r and Linux \n line breaks in the file.
After making the change run the find_whitespace.php page again to insure the file(s) have been successfully updated and the whitespace removed.
If the page is not updated in 2 seconds, please follow this link.
When using modules such as the One Page Checkout that transfer XML data between the browser and the server this whitespace can cause the application to fail. To fix this:
1. Download this script: find_whitespace.zip (1.16 KB)
2. Unzip the find_whitespace.php file and upload it to the root of your X-Cart store.
3. Open this script in a web browser. Example: http://www.yourstore.com/find_whitespace.php
The page will display all files in your X-Cart directory that have extra space after the final ?>

You will need to open these files in a text editor and remove the whitespace. Then re-upload the file to your website.
File with extra whitespace:

Removed:

If your FTP client adds the whitespace again after removing it you will need to upload the file in binary mode (see your FTP client help to change your upload settings). This can be caused by having both Windows \r and Linux \n line breaks in the file.
After making the change run the find_whitespace.php page again to insure the file(s) have been successfully updated and the whitespace removed.
Still Have Questions?
If you are unable to find a solution in the knowledgebase please open a support ticket for a personal response from the support desk.
Related Articles
- I'm receiving this error on the checkout page: "There was an error loading the shipping options, please try again. (You may need to refresh your browser.)"
This error is generally caused by either a PHP headers error, a cannot redeclare a function error, a PHP file containing whitespace or lines after the final ?>, or an installation error. Go to admin/logs.php and... - I'm receiving a file is corrupt error when download a file using the Download Expander link.
A corrupt file can be caused by a number of different items. 1. Whitespace being sent out of the PHP file before the contents of the zip file. If you see this message on your site sometimes " If... - I've contacted X-Cart tech support about a problem and they say the problem is in the One Page Checkout. How can I tell what is an X-Cart issue vs. a One Page Checkout issue?
To determine if the X-Cart code is the cause, or if the One Page Checkout is the cause, you can switch back and forth between the default multi-page checkout and the One Page checkout for your...
Rate or comment on this article
Rate This Article (Select a star)



Add Comment