October 23rd, 2000, 11:51 AM
I insert text into a MySQL Database using a TEXT field.
PHP syntax is:
$query = "INSERT INTO data (text_field) VALUES('$text_field')";
The problem is, when the user has an apostroph (like "friggin' cool") in the text, MySQL misinterprets it, and the query is invalid. Is there a PHP function that formats the that input so it can be entered into the database?
October 23rd, 2000, 12:08 PM
I guess u don't like reading manuals eey..
and never ever ask again
October 23rd, 2000, 12:37 PM
Hey lewi, why don't you not be a jerk, eey? Or is there no manual on that?
October 24th, 2000, 05:18 AM
Ah, now i get it
u can't stand a comment
October 24th, 2000, 05:38 AM
I don't think Lewi is being a jerk. He's trying to teach people how to learn to program.
asuzuki: you want to know how to write a string to a database? How about chapter 7 of the MySQL manual:
7 MySQL Language Reference
7.1 Literals: How to Write Strings and Numbers
That might give you an idea of why you need addslashes(), instead of just knowing that if you do it that way, it works.
Dogg: That's why it's important that you tell people like this to read the manual. He would of gone on using addslashes(), found out it worked, but had no idea why it worked. You don't learn how to program by writing a bunch of code you don't know, then get other people to debug it for you, and then call yourself a programmer. That's how you become a manager, not a programmer.
Hopefully I've made myself clear...
Questions like this are why I even added a signature.
* The manual can probably answer 90% of your questions...
* PHP Manual. www.php.net/manual
* MySQL Manual: www.mysql.com/documentation/mysql/bychapter
October 24th, 2000, 05:56 AM
thnx for backup, and you r absolutely right
just trying to learn people how to program.
but i't not that those people don't have to think
by theirself, and ask first instead of thinking and
if u want to learn how to program u should learn how
to read the manual first, and how to find information
in that manual.
1st read the manual entirely (not every word, but some parts
all over the place)
u don't have to memorise everything, almost every answer i gave on
this forum was created by someone else, i just found the answer
by looking at the right place..
at php.net there r even user notes on how to use the functions, it
can't be much easier..
well ok, u can ask people first (but u won't learn from that)
i don't want to be like a jerk, and even in this case i tried NOT
to be like a jerk
October 24th, 2000, 08:14 AM
sorry for having wasted your time, I was just probably too lazy to lookup a manual or a book. But don't worry, I will keep asking questions when I need a fast answer...
October 24th, 2000, 08:57 AM
Lewi, you really are a jerk aren't you. :-)
"1st read the manual entirely" (!!)
The PDF Manual I use is 723 pages long. Do I need to explain why your argument fails?
"if u want to learn how to program u should learn how to read the manual first"
Yeah. That's cool. You said "how to", which is how to search, browse, etc.
If you don't have much knowledge of scripting (ohh, PHP is not programming, it's scripting by default) or DB admin, then it's going to be very difficult to know what you are lookin for.
"Hmm, that SQL doesn't work, perhaps I should configure mySQL", the newbie thinks.
Bottom line. Be rude as you have all the right be to people who are lazy and not searching the forums or the manual, but be kind to people who don't even know what they're looking for.
¬ peterbe.com ¬
October 24th, 2000, 09:43 AM
1st yeah, read it... but i didn't say read it
all.. just look ad the headings etc.. and read parts of it.
2d.. i guess u misunderstand me, ..ah well
3d your absolutely right.. it is a scripting language.. sort of programming still, but ok, and if u can install php, then little things shouldn't be a problem
and bottom line..
i DIDN'T intended to be rude, and i won't try to be also, unless someone is rude to me
nice comments though discussion although
October 24th, 2000, 09:57 AM
I would like to say that because im dutch, and english is not my foreign language, it's sometimes hard to even understand the manual!!
And i don't find the php manual complete!!
look for fsockopen! after reading the manual about that, i didn't understand exactly what fsockopen does!! what is easy for you isn't easy for other people.
Until next time, I'll Remain!!
Quote the Dokus:"NeverMore!"
October 24th, 2000, 10:07 AM
Ik ben ook nederlands
(meaning: i'm dutch to)
But heey, i understand it..
and offcourse there are some..erm
lot's off missing parts, .. and then any forum would be very handy
October 24th, 2000, 10:20 AM
I am Swiss and I have actually no problems reading an english manual. Look, the point is that we have been "wasting" a considerable ammount of time just discussing this issue, despite the actual issue (my question) being solved in what, a few seconds of your time?
October 24th, 2000, 10:26 AM
Yeah, about 0.30 seconds
but the discussion is going to be much longer
October 24th, 2000, 10:34 AM
October 24th, 2000, 01:23 PM
I'm sorry that I called you out like that if you weren't trying to be rude.
I agree the manuals hold the answers to most question and people often don't think enough for themselves.
What I did not appreciate was the "never ask again" comment since it made it seem as if the initial question was inappropriate. (I realize I could have taken this the wrong way, though.)
I think that this forum is great. It is great because people feel free to ask questions and others can learn from their mistakes. It is also great because people like Lewi have the answers to those questions and others can learn from their wisdom.
I would hate it if people felt that they couldn't ask a question freely anymore because the answer is somewhere in the manual.
I would also hate it if people like Lewi stopped answering questions because I can learn a lot from them.
I am sorry that I offended people. Please accept my apology.