+ 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.
7 odpowiedzi
+ 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!
+ 3
did you try turning it off and on again?
+ 2
i guess you didnt escape the '. thus the string will end with this character. but as Alexander Sokolov mentioned, please provide your code.
+ 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"
+ 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.
+ 1
Then how to find that the user entered ' character and replace with \'
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