I have gone crazy with this. It looks very simple.
I have asterisk 1.8, php5.3, Mysql 5.1
Here is my PHPAGI script,
!/usr/bin/php -q
noop("AGI executing ..... ");
//CONNECTING TO DATABASE
$con = mssql_connect('CMDNYCDYN01','user','pass') or die('ERROR : Could not connect to the server!');
if (!$con)
mssql_select_db('IssueTracking') or die('ERROR : Could not select a DATABASE');
//SCAN FOR AN EXISTING TICKET
// This is the VARIABLE coming from DialPlan. It is correct
$ticket= $argv[1];
$query = "SELECT IncidentNumber ";
$query .= "FROM IssueTokenMaster ";
$query .= "WHERE IncidentNumber='$ticket'";
$result = mssql_query($query);
//Check if a record exists or not
$Count = mssql_num_rows($result);
if ($Count > 0){
$found = $agi->set_variable("FOUND","YES");
}
else{
$found = $agi->set_variable("FOUND","NO");
}
$agi->noop("The Value of found is $found");
//FREE MSSQL RESULT
mssql_free_result($result);
mssql_close($con)
?>
I always get the "ELSE" PART executed, even though row count is greater than 1.
If I run the script in the browser to test my query, I get the the right results. When I run this using the AGI, it only executes the ELSE part.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi there,
I have gone crazy with this. It looks very simple.
I have asterisk 1.8, php5.3, Mysql 5.1
Here is my PHPAGI script,
!/usr/bin/php -q
noop("AGI executing ..... "); //CONNECTING TO DATABASE $con = mssql_connect('CMDNYCDYN01','user','pass') or die('ERROR : Could not connect to the server!'); if (!$con) mssql_select_db('IssueTracking') or die('ERROR : Could not select a DATABASE'); //SCAN FOR AN EXISTING TICKET // This is the VARIABLE coming from DialPlan. It is correct $ticket= $argv[1]; $query = "SELECT IncidentNumber "; $query .= "FROM IssueTokenMaster "; $query .= "WHERE IncidentNumber='$ticket'"; $result = mssql_query($query); //Check if a record exists or not $Count = mssql_num_rows($result); if ($Count > 0){ $found = $agi->set_variable("FOUND","YES"); } else{ $found = $agi->set_variable("FOUND","NO"); } $agi->noop("The Value of found is $found"); //FREE MSSQL RESULT mssql_free_result($result); mssql_close($con) ?>I always get the "ELSE" PART executed, even though row count is greater than 1.
If I run the script in the browser to test my query, I get the the right results. When I run this using the AGI, it only executes the ELSE part.