I have a chat with Flash AS3 i php and I have a Hostinger bd
The chat works fine but sends or receives duplicate records by pressing the Send button.
That is, when I press the send button as you can see in the image, two different ids for the same message come out.
Here below I leave the php code
submitScoreProvaMar.php
<?php
$user = 'u640465832_mar';
$pass = 'xxxxxxxx';
$dbName = 'u640465832_usuar';
$mysqli = new mysqli('mysql.hostinger.es', $user, $pass, $dbName);
if($mysqli->connect_errno)
{
echo "Failed to connect: " . $mysqli->connect_error;
}
$user = $_POST['user'];
$missatge = $_POST['missatge'];
$query = "INSERT INTO provaMar (User, Missatge) VALUES ('" . $user . "', '" . $missatge . "')";
$mysqli->query($query);
$result = $mysqli->query($query);
$returnValue = $result->num_rows;
$mysqli->close();
echo $returnValue;
?>
getScoresProvaMar.php
<?php
$user = 'u640465832_mar';
$pass = 'xxxxxxxxxx';
$dbName = 'u640465832_usuar';
$mysqli = new mysqli('mysql.hostinger.es', $user, $pass, $dbName);
if($mysqli->connect_errno)
{
echo "Failed to connect: " . $mysqli->connect_error;
}
$query = 'SELECT * FROM provaMar ORDER by Datetime DESC limit 10';
$result = $mysqli->query($query);
$returnString = '';
while($row = $result->fetch_assoc())
{
$returnString .= ($row['Datetime'] . "\n");
$returnString .= ($row['User'] . ' diu: ' .$row['Missatge']. "\n");
}
echo "returnString=" .$returnString;
?>
and the AS3 code in Flash
He will not let me publish flash code. Flash code AS3
If someone knows why he sent it in duplicate, he will do me a favor Very grateful