Home > database >  how do i deal with missing string in MySQL?
how do i deal with missing string in MySQL?

Time:06-02

I want to insert data into my table but when I press "enter" nothing happens and the next sentence starts with '>. I know it means missing string but I don't see it this is my code

INSERT 
INTO events
VALUES
('13', '2021.03.13', 
'vet', 
'Dehidration. Spider's body loses more fluids than it does take in. If spider is not threated, it can get worse and become a serious problem.',
'10',
'5'); 

then it shows "'>" how to deal with this?

CodePudding user response:

The fourth value that you are entering contains a ' which is closing the string early, try this;

INSERT INTO events VALUES ('13', '2021.03.13', 'vet', 'Dehydration. Spider\'s body loses more fluids than it does take in. If spider is not threated, it can get worse and become a serious problem.', '10', '5');

In this case the \ lets the database know that you want to store the character ', instead of ending the string early.

CodePudding user response:

Please use this mysqli_real_escape_string(db_connection, $your_string)

OR

you may write single quote like this => \'

  • Related