You might say that this question already asked many time! You right, but those dont give me solution. I am trying to insert inserted data and two var into database using trigger on insert event, code is here:
< html > <body >
<?php
$s = $_POST['sent'];
echo "Entered sentence : $s";
$a = array();
$b = array();
if (preg_match_all('/[^=]*=([^;@]*)/', shell_exec("/home/technoworld/Videos/LinSocket/client '$s'"), $matches))
//if (preg_match_all('/[^=]*=([^;@]*)/', shell_exec('/home/technoworld/Videos/LinSocket/client '.escapeshellarg($s)), $matches))
{
$a[] = (int) $matches[1][0]; //optionally cast to int
$b[] = (int) $matches[1][1];
}
$x = (int) $matches[1][0];
$y = (int) $matches[1][1];
$p=10;
$q=20;
echo $x;
echo "<br/>";
echo $p;
echo "<br/>";
//---------------DB stuff --------------------
$con = mysqli_connect('127.0.0.1:3306', 'root', 'root', 'test');
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: ".mysqli_connect_error();
}
$sql2 = "CREATE TRIGGER MysqlTrigger AFTER INSERT ON table1 FOR EACH ROW BEGIN INSERT INTO temp VALUES (NEW.sent,'".$x."','".$p."');";
mysqli_query($con,$sql2);
$sql1 = "INSERT INTO table1 (sent)VALUES('$_POST[sent]')";
if (!mysqli_query($con, $sql1)) {
die('Error: '.mysqli_error($con));
}
echo "1 record added";
mysqli_close($con);
?>
</html > </body >
Data is inserted in table1 successfuly and trigger event also works. But on trigger NEW.sent gets inserted while rest two var always inserted as "ZERO"- 0. Looking at various solutions given on web I tried with :
(NEW.sent,'$x','$p');";
(NEW.sent,"$x","$p");";
and other but every time it insert 0 for this two values.
Data type of $x and $p is Integer and In table I have taken int values for this two paramter. What is the issue?