+ 2

Why it is not working

I cannot add the ' character . I am creating a chat app. And when the user enters a text Example: I'm . It's not storing in the database why. What can I do.

21st Jul 2018, 12:06 PM
Vj Abishek
Vj Abishek - avatar
7 ответов
+ 3
Hello, vj abishek ! Please provide your code, Sololearn has such an opportunity. so that other people can solve your problem. Good luck in programming on SoloLearn!
21st Jul 2018, 12:14 PM
Alexander Sokolov
Alexander Sokolov - avatar
+ 3
did you try turning it off and on again?
21st Jul 2018, 10:11 PM
voja
voja - avatar
+ 2
i guess you didnt escape the '. thus the string will end with this character. but as Alexander Sokolov mentioned, please provide your code.
21st Jul 2018, 12:19 PM
Mau
Mau - avatar
+ 1
vj abishek The character ' is a special character and needs to be escaped with backslash \ Normal sentence: I'm coding. String: "I\'m coding"
21st Jul 2018, 12:19 PM
Hoàng Nguyễn Văn
Hoàng Nguyễn Văn - avatar
+ 1
Sorry there is a grammar mistake in the first line: I cannot add the ' character. I m using the code $sql = $mysqli->query("INSERT INTO chat(value)" ."VALUES('$value')"; When the user enters "I'm" It is not storing in database why.
21st Jul 2018, 12:20 PM
Vj Abishek
Vj Abishek - avatar
+ 1
Then how to find that the user entered ' character and replace with \'
21st Jul 2018, 12:24 PM
Vj Abishek
Vj Abishek - avatar
0
presumably, u have a string and it is in 'some text', single quotation marks, and within the string u have another ' (apostrophe) which is supposed to be a part of ur text, but actually ending the string. Like, 'good that I'm a learner'. here starting mark is ended because of the I'm apostrophe. to deal with that, just escape that apostrophe with \, like I\'m. another solution would be using the string in double quotation marks so that it doesn't contradict with the ur string
21st Jul 2018, 2:32 PM
Ikboljon Sobirov
Ikboljon Sobirov - avatar