Not sure how to word this but my problem is that my fields will not update properly. I have a page set up where the user can update things like job listings, events, etc. The problem is that some of the descriptions are 3 or more paragraphs long and when the form is processed, it doesn’t update the database correctly. This also happens when the user makes a new item.
Is there a limit on how much text can be loaded at once?
Here is the code for updating that I am using:
mysql_query("UPDATE tbl_workers_club SET eventdate='".$newDate."', theme='".$theme."', text='".$text."', contactperson='".$contactperson."', contactphone='".$phone."', dateentered='".$dateentered."' WHERE specialID='".$id."' ");
Here is the code for new items:
mysql_query("INSERT INTO tbl_workers_club (eventdate, theme, text, contactperson, contactphone, dateentered)
VALUES ('$newDate', '$theme', '$text', '$contactperson', '$contactphone', '$dateentered')");
I did not see another question like this so if you know of one let me know.
Saying what errors you’re getting (or no errors) would greatly help diagnosing this problem. Is the content merely “cut off” in the database? Or is MySQL throwing errors back to PHP? However, here are some ideas…
mysql_real_escape_string() is a good place to start. Any input with a single apostrophe will break your code. Read up on cleansing user input for SQL, there are tons of resources on the web. It’s absolutely not optional. Also look into parameterized queries / prepared statements, or one of the many ORM libraries/frameworks out there.
It’s also possible that your “text” column is not large enough to hold those inputs, if you’re only having problems for very long entries. VARCHAR(X) can only hold X characters. Use something like MEDIUMTEXT instead.
Use POST rather than GET; GET has limits on the size of values sent via the URL. POST is the conventional method when sending requests that create/alter data.
It’s hard to say what the problem is without more info on what errors you’re getting.