3
I’m at an impasse about storing an HTML in the comic.
I’m using the php property: htmlentities($_POST['codhtml'])
to perform this operation. However, when saving a code such as:
<span class="frase-aditivo mover" id="adt6-enable" style="transform: translate3d(-2px, 202px, 0px); cursor: move; touch-action: none; -webkit-user-select: none; z-index: 1004; border: 3px dashed red; font-size: 112px; font-family: "Comic Sans MS"; color: rgb(0, 64, 128);">Leve a alegria do Natal para sua casa ! </span>
In the bank is stored:
<span class="frase-aditivo mover" id="adt6-enable" style="transform: translate3d(-2px, 202px, 0px); cursor: move; touch-action: none; -webkit-user-select: none; z-index: 1004; border: 3px dashed red; font-size: 112px; font-family:
That is, for some reason the code is lost whenever there is a URL or after "font-family:".
What is the best way to accomplish this rescue ?
PS. I am using Longtext.
Thank you =D
/* Continuation CODE*/
$("#mt_finalizar").click(function(event) {
var codhtml = '<span class="frase-aditivo mover" id="adt6-enable" style="transform: translate3d(-2px, 202px, 0px); cursor: move; touch-action: none; -webkit-user-select: none; z-index: 1004; border: 3px dashed red; font-size: 112px; font-family: "Comic Sans MS"; color: rgb(0, 64, 128);">Leve a alegria do Natal para sua casa ! </span>';
$.ajax({
type : 'post',
url : 'salvarDados.php',
data : 'codhtml='+codhtml
+'&motivoid=2'
+'&formatoid=2'
+'&motivonome=Nome',
dataType : 'html',
success : function(txt){
alert("Sucesso,");
},
error: function(result) {
alert("Erro ao Salvar");
}
});
$resultado = $this->conexao->exec("INSERT INTO tabela (col1,col2,col3,col4,col5,col_codhtml,col6) VALUES(2,2,2,2,2,'$codhtml','Nome')");
I use base64_encode and base64_decode when saving HTML in the database.
– Mayron Ceccon
@Mayronceccon bad habit. It takes up much more space, and has no advantage. Moreover it is an encoding process and a decoding process the most totally unnecessary. Here’s the suggestion to learn better how to use DB and language features to improve your apps.
– Bacco
Dude, I know blob type saves file and stuff, I think it’s valid you test with it.
– PauloFlesch
I tried to use this base_64 but the string is broken in the same way. I will try to use the type blob.
– user48796
@user48796 your problem shouldn’t be in DB, it’s probably in the way you’re doing Insert. Even if it worked, Base64 would only disguise the problem. Only if you don’t post the code in the question, it won’t work. Probably your question has already been solved in this post: http://answall.com/questions/21318/70
– Bacco
@Bacco Thanks for the support ! I believe the error is at the time I pass the parameter HTML, when it finds the '&' it interprets as a new parameter... I’d have a solution for that ?
– user48796