ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Hello. My server has php magic quotes turned on. When I add a record to a MySQL row, like "britney's favorite color is pink" and then fetch the value of the row into a text input with mysql SELECT, the only part of the data that comes back is "britney" -- it always cuts off at the apostrophe, single-quote, and other symbols like "&".
I have tried combinations of addslashes, stripslashes, etc, to no avail. Can anyone tell me how to get php to populate the _entire_ row data into the text input?
Thanks!
Noah
edit: 2.5 hours later -- still unable to get this to work -- any suggestions? pulling my hair out
Thanks for the reply! I am killing myself over this... and unfortunately, it's still not working. I have tried many permutations of addslashes and stripslashes but that doesn't seem to work. I can get MySQL into the database, as either escaped or unescaped strings.
For example, I can insert either "britney\'s tight ass" or "britney's tight ass"
But whenever I fetch the info back into a text input with a while loop and call from the resulting array, I get only "britney" either way.
It works alright, but I wonder if it will work outside of text areas. If you use both methods and compare the source code, you'll see that using the function outputs html-compliant code, but the concatenater outputs literal quotes, tags and other special characters.
Might that cause problems? Might it allow the insertion of code into your web pages? (one might not mind that, but it might open a door to malicious code inserted by a user.)
Yes, the special characters were parsed by my browser when the variable was output in a page.
So, I'll use the htmlspecialchars function to prevent evil code showing up on my web pages.
Also, I found another function (in the book 'Beginning PHP, Apache, MySQL Web Development by wrox publishers) which will preserve the line breaks. It's nl2br().
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.