Jump to content
New Reality: Ads For Members ×

data attribute


Destramic

Recommended Posts

hey guys i have a data attribute with a json string of about 291478 characters long so far and counting...but im thinking the data attribute has a max length (although im unable to find any details on this so far) as my json string gets cut off 3/4's of the way through

 

when i echo string outside data attribute it shows perfectly fine...does anyone know the max length?

 

also i need to find somewhere else to store this json string...the data attribute had been perfect up until now! :(

Link to comment
https://forums.phpfreaks.com/topic/298145-data-attribute/
Share on other sites

Data attributes are unlimited but do have limits due to system memory. You should consider these more like meta fields and output data normally.

Strings have a limit of 2GB but the overall script execution also has a limit determined by your php.ini memory settings and also server resources.

 

If you are having memory issues you may want to rethink how are fetching and displaying the data.

 

json_decode() the json file and store data into a database

 

Can read from saved json files directly like a cache but have to load the entire file each time and parse it.

Link to comment
https://forums.phpfreaks.com/topic/298145-data-attribute/#findComment-1520747
Share on other sites

well the data originally comes from the database then i use

	public function encode($data = array())
	{
	    $utf8 = new UTF8();
	    $data = $utf8->encode($data);
	    
		$json = json_encode($data);
        $json = htmlentities(stripslashes($json), ENT_QUOTES);

        return $json;
	}

to encode to json so i can use the data via js....and i call the data like so:

sub_category.data('sub-categories');

the after encoded the json looks like a perfect json string....but when added to the data attribute it only has about 3/4 of the data and not formed correctly

Link to comment
https://forums.phpfreaks.com/topic/298145-data-attribute/#findComment-1520756
Share on other sites

ok well this is embarrassing my json isn't valid

 

basically i have 3 columns like so:

"name":"10"      Singles"

10" Singles   -    but because of the quote make which represents inch, json fails.

 

strip slashes worked like a charm....thank you

Link to comment
https://forums.phpfreaks.com/topic/298145-data-attribute/#findComment-1520761
Share on other sites

Archived

This topic is now archived and is closed to further replies.



×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.