Hello everyone, I recently encountered such a problem. When queried to the database, data with quotation marks are displayed without them. For example, I write Name in LLP and add it to the database. In the database, the word is with quotes. When prompted, the word is displayed before the quotes: for example, LLP (should be LLP "Name"). With this code, I replace the quotes with spaces and thus the word is displayed. $changed= str_replace('"',' ',$row->name); And then the whole word is output, but without quotes. Are there any other ways to output words without losing characters

  • one
    I did not understand anything, but let it be htmlspecialchars . - check1st
  • one
    I did not understand anything, but let him not use eval. - Qwertiy

2 answers 2

Use http://php.net/manual/ru/function.htmlentities.php or http://php.net/manual/ru/function.htmlspecialchars.php
When adding a record to the database, use the prepeared statements

    Try zaeskeypit all objectionable characters, including quotes, through mysql_real_escape_string() get something like this:

     $myvar = "ТОО 'Имя'"; $myvar = mysql_real_escape_string($myvar); $query = "INSERT INTO mytable VALUES('$myvar',...);" 
    • No need to recommend the use of outdated and disabled in the latest versions of the extension. At a minimum, you need anadlog for mysqli, and it is better to use the parameters of the prepared request. - artoodetoo