I have a function that generates a random text with about 8,000 characters.
This text is generated at the time of first access the page, based on some parameters.
I would like this text to be storing in the database (not to be necessary to generate another text to each access).
I successfully stored in the database all the variables except the large text. Also could store when the text is small:
$LargeText=Texto(); //-> about 8,000 characters
if(empty($Descricao)){
$InserirDescricao = strtoupper($Nome);
mysql_query("UPDATE lavanderias SET descricao = \"$InserirDescricao\" WHERE id=$CidadeID");} //-> This works fine
if(empty($Texto)){
mysql_query("UPDATE lavanderias SET texto = \"$LargeText\" WHERE id=$CidadeID");} //-> This not works :(
if(empty($Texto)){
mysql_query("UPDATE lavanderias SET texto = \"ANYTHING\" WHERE id=$CidadeID");} //-> This works fine
The third message generates this error message:
Fatal error: Uncaught exception 'mysqli_sql_exception' with message
'You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near
'servico"><div class="servico-ilustracao servico-ilustracao-5"><h2>Lavagem de Pro'
at line 1'
It is possible that the number of characters is preventing the insertion? How do I manage to insert the variable with the large text?
mysqli
API and use prepared statements. It is much easier to avoid security vulnerabilities with it.