我无法解决问题,该脚本的目的是识别上下文编号。
以下是星号拨号计划extensions.conf
exten => 1234,1,Answer()
same => n,Set(NUM2CALL=Hello, your number is eight)
same => n,NOOP(${NUM2CALL})
same => n,AGI(test.php,${NUM2CALL})
运行test.php的文件
#!/usr/bin/php -q
<?php
require '/var/lib/asterisk/agi-bin/phpagi/phpagi.php';
$agi = new AGI();
//DB connect
$mysqli = new mysqli('127.0.0.1', 'root', 'testdatabase', 'asterisk');
if (mysqli_connect_errno())
{
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
//End
$query = "SELECT text, number FROM recognation_2";
$result = $mysqli->query($query);
while ($row = $result->fetch_object())
{
if(strpos($argv[1], $row->text) !== FALSE)
{
echo $row->number;
}
}
?>
最佳答案
你在开玩笑吗?为什么不问db一行呢?
$query = "SELECT text, number FROM recognation_2 where text = "+mysqli_real_escape_string($mysqli,$argv[1]);
最好的选择是使用func_odbc,不需要任何php或agi。