You're giving this error:
Parse error: syntax error, unexpected 'if' (T_IF) in C: \ Program Files \ EasyPHP-Devserver-17 \ eds-www \ Hugg \ sys \ historico.php on line 3
I've been looking for the solution for some time but I can not find it. The error is in this line:
if(isset($_POST['mensagem'])){
The code:
header("Content-Type: application/json;charset=utf-8");
if(isset($_POST['mensagem'])){
include_once "../defines.php";
require_once('../classes/BD.class.php');
BD::conn();
$mensagens = array();
$id_conversa = (int)$_POST['conversacom'];
$online = (int)$_POST['online'];
$pegaConversas = BD::conn()->prepare("SELECT * FROM 'mensagens' WHERE ('id_de' = ? AND 'id_para' = ?) OR ('id_de' = ? AND 'id_para' = ?) ORDER BY 'id' DESC LIMIT 10");
$pegaConversas->execute(array($online, $id_conversa, $id_conversa, $online));
while($row = $pegaConversas->fetch()){
$fotoUser = '';
if($online == $row['id_de']){
$janela_de = $row['id_para'];
}elseif($online == $row['id_para']){
$janela_de = $row['id_de'];
$pegaFoto = BD::conn()->prepare("SELECT 'foto' FROM 'usuarios' WHERE 'id' = '".$row['id_de']."'");
$pegaFoto->execute();
while ($usr = $pegaFoto->fetch()){
$fotoUser = ($usr['foto'] == '') ? 'default.jpg' : $usr['foto'];
}
}
$emotions = array(':P', ':$', ':|', ':O', '<3', ';*', ':%', ':@', ':D', ';D', ':A', ':"(', ':(', ':Z');
$imgs = array(
'<img src="smiles/tongue.png" width="16" height="16" border="0"/>',
'<img src="smiles/redface.png" width="16" height="16" border="0"/>',
'<img src="smiles/nada.png" width="16" height="16" border="0"/>',
'<img src="smiles/espanto.png" width="16" height="16" border="0"/>',
'<img src="smiles/blowkiss.png" width="16" height="16" border="0"/>',
'<img src="smiles/kiss.png" width="16" height="16" border="0"/>',
'<img src="smiles/zangado.png" width="16" height="16" border="0"/>',
'<img src="smiles/mad.png" width="16" height="16" border="0"/>',
'<img src="smiles/rindo.png" width="16" height="16" border="0"/>',
'<img src="smiles/rindo2.png" width="16" height="16" border="0"/>',
'<img src="smiles/anjo.png" width="16" height="16" border="0"/>',
'<img src="smiles/choro.png" width="16" height="16" border="0"/>',
'<img src="smiles/triste.png" width="16" height="16" border="0"/>',
'<img src="smiles/dormindo.png" width="16" height="16" border="0"/>'
);
$msg = str_replace($emotions, $imgs, $row['mensagem']);
$mensagens[] = array(
'id' => $row['id'],
'mensagem' => utf8_encode($msg),
'fotoUser' => $fotoUser,
'id_de' => $row['id_de'],
'id_para' => $row['id_para'],
'janela_de' => $janela_de
);
}
die(json_encode($mensagens));
}
I put it full here .