Hi Folks,
I need to store double quotes in my mysql db.
Can anyone tell me the best way to do it?
I can’t edit my php.ini file. Here is my code so far:
$query = “INSERT INTO productDim(dimproduct, dimtext) VALUES($productid, ‘$textencode’)”;
Can you please supply me with some sample code.
Many thanks
system
2
INSERT INTO tblperson (fldFamilyName) VALUES ('"fred"');
The manual is your friend: http://us.php.net/manual/en/book.pdo.php
$statement = $db->prepare("INSERT INTO productDim(dimproduct, dimtext) VALUES(:productid, :textencode)");
$data = array('productid' => $productid, 'textencode' => $textencode);
$statement->execute($data);
Use PDO and never worry about those pesky quotes again.
PHP is flexible.
Whenever we want to have single quote in output or in table, use double quote, vice versa.
system
5
another option can be to use mysql_real_escape_string() to escape the quotes for you.