I need to know if there is a variable limit size with PHP. I'm taking a string field from an SQL database and using echo to view it on a web page. The problem I am running into is that, when I view the web page, I don't see everything that is in the database field. Is there a limit on how much can be in a PHP variable? Is there a way I can make PHP read the entire entry from the database and not stop partway?
-
How big is the column you're trying to output?Michael Mior– Michael Mior2011-07-07 15:07:38 +00:00Commented Jul 7, 2011 at 15:07
6 Answers
The amount of data a variable can hold is limited only by the amount of memory available to PHP. If you meet or exceed this limit, page execution will end and you will likely encounter a PHP error. Data contained in a variable will not be truncated silently.
Please note that most database field types do have explicit limits on the amount of data that can be stored in them. You may wish to confirm that the data really exists in the database as expected, and is not being truncated at the time it is inserted.
You should also check the output by viewing the HTML source. If the expected data appears when viewing the source, but does not display when the page is rendered in a browser, you may need to escape the data to remove any HTML entities that the browser is interpreting as markup.
1 Comment
The variable size is limited by the amount of memory available to PHP. To increase PHP's memory limit, you can modify the memory_limit in the php.ini file, if that option is available to you on your server. Otherwise, you can use ini_set at the beginning of your script.
ini_set('memory_limit','16M');
1 Comment
It's unlikely to be a memory problem. PHP wouldn't silently chop a string down to size, it'd just die with an out-of-memory error.
Is the string you're outputting truncated (end chopped off), or are parts missing from the middle? Remember than when viewing in a browser, anything that looks like an HTML tag will be interpreted as such. If your text contains a < somewhere, then anything after that MAY be hidden as part of an unknown tag, until a > is found later.
It's not likely to be a database problem either, as MySQL would issue an error if the size of the data exceeds the max_allowed_packet limit.
7 Comments
< in there. Try viewing the SOURCE of the page, instead of just directly in the browser window.>. Even if i can view the data via view source it wont help because i have to fetch the data from sql and insert into mysql ....echo strlen($your_eps_string) to see how long PHP thinks it is, v.s. what the reported length is in the database.The solution was ini_set('odbc.defaultlrl', 65536);
1 Comment
The variable size is limited only by the amount of memory available to PHP. To increase PHP's memory limit, see this post:
With regards to your problem, there must be some other factor affecting your output. Please post your code for help with that.