Error Based on Accentuation

Asked

Viewed 328 times

6

Hello!

I’m developing a Hybrid APP that uses a PHP Webservice to send an email and call a Procedure in Mysql by filling it with the same email details, until the email sending part is OK it sends successfully , however at the moment I am going to send the data to Procedure it simply does not error and does not execute anything.

I created a PHP part with a form and the same content of the webservice that is used by the APP , when I fill in the form I noticed that it mounts the GET URL by formatting the data by making the accent adjustments and removing the @ and replacing it with %40 ( ASCII code) and so the Wheel successfully.

In the case of App PHP Recovers data from JSON sent by APP and turns it into variables , I tried to force an accent conversion but it didn’t help any idea what to do?

Follow the codes:

APP version

 <?php

Include("dbconect.php"); #DB Connector

if (!empty($_GET)) {

/* Recuperando Dados do GET */
$DestinoEmail = "[email protected]"; //Destino para o Email de     Notificação

$NomeCompleto  = $_GET['Nome'];
$TelefoneFixo  = $_GET['TelefoneFixo'];
$TelefoneMovel = $_GET['TelefoneMovel'];
$email         = $_GET['Mail'];
$cor           = $_GET['CorSelecionada'];
$Rg            = $_GET['NumeroRG'];
$cep           = $_GET['NumeroCEP'];
$assunto       = $_GET['AssuntoEmail'];
$descricao     = $_GET['descricaoEmail'];
$mobileID      = $_GET['MobileReg'];
$sexo          = $_GET['Sex'];
$nCasa         = "0";

/* Envia o email notificando */

#Corpo do Email
$msg= "<!DOCTYPE html>
    <html>
       <head>
          <meta charset='utf-8'>
          <style type='text/css'>
          body {

           color: #3A6EA5;
          }

          h5 {
              background-color: #3A6EA5;
              padding: 10px 30px 10px 30px;
              width: 950px;
          }
          </style>
       </head>
       <body>
          <p>&nbsp;</p>
          <p>Prezado $NomeCompleto,</p>
          <p>Seu Teste foi encaminhado com sucesso para nossa linha , favor aguarde retorno.</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
        </body>
    </html>";

# Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <[email protected]>' . "\r\n";
$assuntoMail = "Teste de Material";
#Codificar Assunto para aceitar os acentos 
$assunto_codificado = sprintf('=?%s?%s?%s?=', 'UTF-8', 'B', base64_encode($assuntoMail)); 
#Quebra de Linha caso a linha ultrapasse 70 caracteres
$msg = wordwrap($msg,70);
#Envio do Email
mail($DestinoEmail,$assunto_codificado ,$msg,$headers);

/*  Executar a Proc para armazenar os dados       */


$ncasa = "0";
$sth = $db->prepare('CALL     PR_REGISTER_REPORT(?,?,?,?,?,?,?,?,?,?,?,?,@out)');
$sth->bindParam(1,  $NomeCompleto, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(2,  $TelefoneFixo, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(3,  $TelefoneMovel, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(4,  $email, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(5,  $cor, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(6,  $Rg, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(7,  $cep, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(8,  $ncasa, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(9,  $mobileID, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(10, $sexo, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(11, $assunto, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(12, $descricao, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->execute();


//Retorno OK para o APP
$resultados["validate"] = "ok";
$resultadosJson = json_encode($resultados);
echo $_GET['jsoncallback'] . '(' . $resultadosJson . ');';


}else{

Echo "Interface Somente com APP";

}

?>

Trial version (test-process.php)

<?php

  Include("dbconect.php"); #DB Connector

  if (!empty($_GET)) {

  /* Recuperando Dados do GET */
  $DestinoEmail = "[email protected]"; //Destino para o Email de       Notificação

  $NomeCompleto  = $_GET['Nome'];
  $TelefoneFixo  = $_GET['TelefoneFixo'];
  $TelefoneMovel = $_GET['TelefoneMovel'];
  $email         = $_GET['Mail'];
  $cor           = $_GET['CorSelecionada'];
  $Rg            = $_GET['NumeroRG'];
  $cep           = $_GET['NumeroCEP'];
  $assunto       = $_GET['AssuntoEmail'];
  $descricao     = $_GET['descricaoEmail'];
  $mobileID      = $_GET['MobileReg'];
  $sexo          = $_GET['Sex'];
  $nCasa         = "0";

  /* Envia o email notificando */

  #Corpo do Email
  $msg= "<!DOCTYPE html>
      <html>
       <head>
          <meta charset='utf-8'>
          <style type='text/css'>
          body {

           color: #3A6EA5;
          }

          h5 {
              background-color: #3A6EA5;
              padding: 10px 30px 10px 30px;
              width: 950px;
          }
          </style>
       </head>
       <body>
          <p>&nbsp;</p>
          <p>Prezado $NomeCompleto,</p>
          <p>Seu Teste foi encaminhado com sucesso para nossa linha , favor aguarde retorno.</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
        </body>
    </html>";

# Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <[email protected]>' . "\r\n";
$assuntoMail = "Teste de Material";
#Codificar Assunto para aceitar os acentos 
$assunto_codificado = sprintf('=?%s?%s?%s?=', 'UTF-8', 'B', base64_encode($assuntoMail)); 
#Quebra de Linha caso a linha ultrapasse 70 caracteres
$msg = wordwrap($msg,70);
#Envio do Email
mail($DestinoEmail,$assunto_codificado ,$msg,$headers);

/*  Executar a Proc para armazenar os dados       */


$ncasa = "0";
$sth = $db->prepare('CALL     PR_REGISTER_REPORT(?,?,?,?,?,?,?,?,?,?,?,?,@out)');
$sth->bindParam(1,  $NomeCompleto, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(2,  $TelefoneFixo, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(3,  $TelefoneMovel, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(4,  $email, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(5,  $cor, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(6,  $Rg, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(7,  $cep, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(8,  $ncasa, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(9,  $mobileID, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(10, $sexo, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(11, $assunto, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->bindParam(12, $descricao, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 12);
$sth->execute();


//Retorno OK para o APP
$resultados["validate"] = "ok";
$resultadosJson = json_encode($resultados);
echo $_GET['jsoncallback'] . '(' . $resultadosJson . ');';


}else{

echo"

<form action='test-process.php' method='get'>
Nome Completo:<br>
<input type='text' name='Nome' value=''><br>
Telefone Fixo:<br>
<input type='text' name='TelefoneFixo' value=''><br>
 Telefone Movel:<br>
<input type='text' name='TelefoneMovel' value=''><br>
  Email:<br>
<input type='text' name='Mail' value=''><br>
 Cor:<br>
<input type='text' name='CorSelecionada' value=''><br>
 NumeroRG:<br>
<input type='text' name='NumeroRG' value=''><br>
NumeroCEP:<br>
<input type='text' name='NumeroCEP' value=''><br>
 AssuntoEmail:<br>
<input type='text' name='AssuntoEmail' value=''><br>
  DescricaoEmail:<br>
<input type='text' name='descricaoEmail' value=''><br>
  MobileReg:<br>
<input type='text' name='MobileReg' value=''><br>
Sex:<br>
<input type='text' name='Sex' value=''><br>
<input type='submit' value='Submit'>
</form>";


}

?>

Some solution?

I tried to force from the get a utf8_decode($foo), and the input with utf8_encode($foo) but did not help =(

  • 1

    Already tried to force output with utf8_decode($foo), and input with utf8_encode($foo) ?

  • I tried to force from the get a utf8_decode($foo), and the input with utf8_encode($foo) but it did not help =(

  • I noticed that you have created two different accounts, I recommend that you contact us at http://answall.com/contact and request merged accounts

  • Done! Thank you very much!

  • Tried to use mb_internal_encoding('UTF-8') and mb_http_output('UTF-8'), basically these lines will say that you are working with UTF-8 strings throughout the file.

  • Follow the step by step of this http://answall.com/a/43205/3635, it will probably solve

Show 1 more comment

1 answer

-1

try to use mysql_set_charset('utf8',$conec);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.