Is posting via forms to database limited with PHP?

software development

#1

Hi,

I am newish to PHP and am working on a website where the admin will be able to update the pages via form fields.

I do connect to the db and the page data (text) is truncated after about 4-5 lines on the site. I can validate that the data is truncated in the table on the database.

I need help figuring this out.

<input style=“width: 450px” style=“width: 450px type=“text” name=“formInformation” maxlength=“2048” value=”<?=$varInformation;?>" />

Thanks for any advice…

Kel


#2

I see two possibilities:

  1. What data type do you have set for this column in the database? Perhaps you’re hitting the limit of what it can store.

  2. I see “maxlength=2048” on the input field. How many characters are you getting in before the text is truncated?


#3

Thanks for the response!

The field type is ‘TEXT’. I know the ‘TEXT’ field can hold the data. I have had it inserted in there using phpMyAdmin. But it was when I was attempting to find the character limit at the truncation point is when I found I could insert much more data if it were just numbers, letters and spaces. So this lead me to finding a character that was causing this in the form. So every time I hit words like (we’ll or that’s) the apostrophe clued me in.

So how to deal with that in the PHP code is going to be a new lesson for me.

If you do have advice or know of an article on that I would welcome it, but also at this point I am thankful for your input that led me to this point! Later tonight I’ll hit this again!

Regards,
Kel


#4

Sounds like you’re probably interpolating the content of the input field directly into your SQL query. That’s dangerous — don’t do it. Here’s a quick rundown on how to effectively use PDO and parameterized queries to avoid this problem:

http://stackoverflow.com/questions/60174/best-way-to-prevent-sql-injection-in-php


#5

Thanks for the advice. I am working on it!