First time with this trouble when dealing with a MySQL table.
I'm inserting bar names in a table. If the bar is called "Tim's Bar" and I insert it straight away I get an error and the data is not inserted.
How do you instert properly the ' in the table?
Use mysql_real_escape_string():
http://php.net/manual/en/function.mysql-real-escape-string.php
Use PDO with prepared statements.
$query = $pdo->prepare('INSERT INTO bars (name) VALUES (?)');
$query->execute("Tim's Bar");
It's superior (and safer) than using the mysql(i)_* family of functions directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With