Apostrophes and text disappearing from custom text fields
URL to your eFiction: http://www.jamlyfics.com
Version of eFiction: 3.5.3
Have you bridged eFiction, if so with what?: Nope
Version of PHP: 5.2.15
Version of MySQL: 5.0
Have you searched for your problem: yes
If so, what terms did you try: Just about every combination of profile, edit bio, apostrophe, htmlentities, htmlspecialchars, disappearing text, missing text, custom field, text field, etc.
State the nature of your problem: When a user goes to the Edit Bio page, apostrophes and all text after them are not showing up in the (custom) text fields. It shows up in the profiles and the text is being stored in the database in its entirety. Whenever a user returns to their edit bio page, though, apostrophes and everything after it do not reappear in the text field. If the user wants to save their profile, they have to retype those parts every time.
Do you have a test account for us? User: test/pass: test
Mods/other things: The archive shares its author table with another installation of efiction ( http://beta.jamlyfics.com). Challenge module is activated.
I don't know if this will help, but here is the code I'm using for the form output on one of the text fields in question. The other text fields are exactly the same but use a different label/name/title:
$output .= "<div><label for='favbook'>".$field['field_title'].":</label><INPUT type='text' class='textbox'
name='af_".$field['field_name']."' maxlength='1000' value='".(!empty($user['af_'.$field['field_id']]) ? $user['af_'.$field['field_id']] : "")."' size='20'></div>";
The custom profile code:
$thisfield = $field['info'];
It might be the magic quotes. Is it turned on or off on your host?
Thank you for responding. 🙂
Magic quotes are turned off.
I probably should have asked this earlier, but is there any other information I can provide to clarify my issue or help more on my end?
Man, I feel like such a bother/nag. Does anybody have at least a vague idea of what I can do to solve this? I've been trying different things with htmlspecialchars, htmlentities, stripslashes, etc. but maybe that isn't the issue. Just a nudge in the right direction would be an incredible help.
Probably going to sound like a broken record with this, but thank you guys so much for even just taking a look at the thread. Your time is really appreciated.
Sorry, I don't know much about that kind of thing. I guess the only thing that I would suggest would be to make sure what's being input is actually ' and not the HTML or other equivalent.
Give us an example. Because when I go to the edit bio page using your test account everything worked fine for me.
Here is how the text is entered on the edit bio page.
From there, I click save. It shows up in the profile properly.
When you go back to the edit bio page, however, the full text doesn't reappear in the text box.
Could it be the field type used (tinyint)? Would this be solved if I used a text box (like what's used for the edit bio field) and how would I do that?
Hmm. Would it help if I changed the form code to a text box rather than the small text field it is now? (And if so, how would I do so? I've tried using <textarea> but that doesn't work.) This is still stumping me.
Turn magic quotes on - this should solve the issue. If not, you will need to manually escape the string for special characters like single quotes and apostrophes. For now, check if turning magic quotes off fixes it, else we can try other ways.
I'm unable to turn magic quotes on on my hosting. 🙁 How would I go about manually escaping the string?
(And thank you for the help!)
You will need to use mysql_real_escape_string() or addslashes() while inserting the data into the database and then use stripslashes() while showing it
Man, I just have the worst luck. I tried those three things (in various combinations/orders) but the best to come of that was this:
At worst, I just got an error page or the field no longer showed up on editbio at all.
I checked the table and the data is being stored correctly (with all apostrophes and any text that follows), if that changes anything.
Probably going to seem like an impatient/annoying nag, but I haven't been able to find a solution to this yet. 🙁
In concern with the last piece of advice posted by raidenace, is it possible that I'm not putting those things in the right place(s)?