Tuesday, 15 February 2011

Wordpress plugin causes page to not load/does not display requested data -


Here's a plugin I'm working on. This is to parse a CSV file and display it as a HTML table on the WordPress page, where this shortcode exists.

When I activate the plugin and go to the page containing this shortcode, the page will not load, try to load the page to my browser (Firefox, Chrome) and can not I do not even get the WSOD; Whenever this happens, I check my server statistics and note that CPU usage is at 85% which is very unusual.

After the plugin becomes inactive, the CPU usage comes back to normal (usually 0-14%) and the page containing the plugin's shortcode will load (but obviously the data requested by the shortcode will not be loaded) .

I do not know exactly what is happening due to this.

I have also tried to use examples that I get known work scripts that do the same thing, poster.

The CSV file that was trying to open it was generated by Excel 2003, and the CSV file is in the plug-in folder

The contents of the CSV file are given here:

  make, model, origin, color, mi, option Chevy, Tahoe, Delaware, Black, 10000, LX Ford, F-150, Texas, Red, 5000, Chevy Chevy, Corvette, Utah, Red , 12000, SE Mazda, Mita, Florida, Blue, 90000, LX  

  & lt; ? Php / * Plugin Name: CSV3 plugin URI: Description: HTML shows CSV files as tables Version: 1.0 Author: Crete Author URI: License: * / ad_shortcode ("CSV", "Open CCS_file"); Function open_csv_file () {$ file = file_get_contents (plugin_dir_path (__FILE__). 'Book1.csv'); $ Handle = fopen ("$ file", "r"); $ Data = fgetcsv ($ handle, 1000, ","); $ Color = $ data [3]; $ Option = $ data [5]; Echo ('& lt; Table & gt;'); While creating ($ $ data = fgetcsv ($ handle, 1000, ",")) == FALSE {$ color = $ data [3]; $ option = $ data [5]; // HTML resize (' Lt; tr data-color = '' $ color. '"Data-option ="'. $ Options. '";); Foreign currency ($ index => $ data as val $) { Echo ('& lt; td & gt;'); echo htmlentities ($ val, ENT_QUOTES); echo ('& lt; / td & gt;');} resonance ('& lt; / tr & gt;') ;} Echo (""); fclose ($ handle);}? & Gt;  

Ensure that the file exists in the location, using the plugin_dir_path option for the exact Distress Directory Locations is removing all the data in this file on the second, every refresh, which I think is what you want, so you should try to save it in the database and time cache.


No comments:

Post a Comment