[asterisk-users] Problem w/ MySQL update from perl AGI script
art at impossibleworlds.com
art at impossibleworlds.com
Mon Jul 23 14:30:07 CDT 2007
I've been trying to get a basic 5 question IVR survey working in an AGI script,
and am having trouble with the SQL portion not updating the table. When I take
out all the AGI references, and run just the perl script, the table updates
with no problem(DBname,username,password have been substituted in this example
for the actual values):
#!/usr/bin/perl
#
#
use DBI;
$DATETIME = '123188765' ;
$TIMESTAMP = '8675309';
$dsn = "DBI:mysql:DBname;localhost;3306";
$dbh = DBI->connect($dsn,username,password);
$drh = DBI->install_driver("mysql");
my $Q1 = "8";
my $Q2 = "6";
my $Q3 = "7";
my $Q4 = "5";
my $Q5 = "3";
my $query = "INSERT into caller_data (DateTime, ANI, Q1, Q2, Q3, Q4, Q5)
VALUES($TIMESTAMP,$ANI,$Q1,$Q2,$Q3,$Q4,$Q5)";
$sth = $dbh->prepare($query);
$sth->execute;
$sth->finish;
Then, When I try an put it together with the AGI commands, the IVR works nicely
from a caller prespective, but I get no update in the MySQL table:
#!/usr/bin/perl
#
#
use DBI;
use Asterisk::AGI;
$dsn = "DBI:mysql:DBname;localhost;3306";
$dbh = DBI->connect($dsn,username,password);
$drh = DBI->install_driver("mysql");
$AGI = new Asterisk::AGI;
my %input = $AGI->ReadParse();
my $ANI = $input{'CALLERIDNUM'};
my $TIMESTAMP = $input{'TIMESTAMP'};
$AGI->answer();
$AGI->stream_file('ABdeli-greeting');
$AGI->stream_file('ABdeli-instructions');
my $Q1 = $AGI->get_data('ABdeli-q1', 5000, 1);
my $Q2 = $AGI->get_data('ABdeli-q2', 5000, 1);
my $Q3 = $AGI->get_data('ABdeli-q3', 5000, 1);
my $Q4 = $AGI->get_data('ABdeli-q4', 5000, 1);
my $Q5 = $AGI->get_data('ABdeli-q5', 5000, 1);
my $query = "INSERT into caller_data (DateTime, ANI, Q1, Q2, Q3, Q4, Q5)
VALUES($TIMESTAMP,$ANI,$Q1,$Q2,$Q3,$Q4,$Q5)";
$sth = $dbh->prepare($query);
$sth->execute;
$sth->finish;
$AGI->hangup();
More information about the asterisk-users
mailing list