On 1/10/07, Lee Jenkins <[EMAIL PROTECTED]> wrote:

Ralph Liebessohn wrote:
> Hi,
>
> I'm trying to write a AGI in PHP to get the numbers dialed (with
> read()), save it into a variable to insert it into a SQL server
> database. But I cannot see results into the variable, it always return
> NULL.
> Here is a piece of the AGI.
>
> fwrite(STDOUT,"exec Read my_var|/sound_to_play|5|||15 \n");
> fflush(STDOUT);
> $conn=odbc_connect('MSSQL', 'USER', 'PASS');
> $query = odbc_exec($conn, "INSERT INTO dialed(number)
VALUES('$my_var')");
>
> Even if I only show my_var value or try to use it inside asterisk, the
> value is NULL.
> There is another way to do it? Am I doing a mistake here?
> I'm using Asterisk 1.2.13.
>

I'm not a php guy, but aren't we missing the part that retrieves the
value saved into my_var from the call to READ?

// In this part you run the read command and asterisk
// stores the value into the channel variable "my_var"

fwrite(STDOUT,"exec Read my_var|/sound_to_play|5|||15 \n");

// In this part you are constructing your sql statement
// with a null value cause you didn't make a call to
// GET VARIABLE before constructing your sql.

$query = odbc_exec($conn, "INSERT INTO dialed(number) VALUES('$my_var')");

--

Warm Regards,

Lee



Hi Lee,

thanks for the tip. I tried other methods trying to get the variable value,
but no success.
Doing a GET VARIABLE my_var after READ the "get variable" returns the value
I dialed, but doesn't give the exact value to it. I got Resource ID #1
instead.
Using:
fwrite(STDOUT,"exec read
my_var|//usr/share/asterisk/sounds/please-wait-connect-oncall-eng|5|||15
\n");
fwrite(STDOUT,"get variable my_var \n");
fflush(STDOUT);
$my_var=STDIN;
fwrite(STDOUT,"exec saydigits $my_var \n");

I got it:

AGI Rx << exec read
my_var|//usr/share/asterisk/sounds/please-wait-connect-oncall-eng|5|||15
   -- AGI Script Executing Application: (read) Options:
(my_var|//usr/share/asterisk/sounds/please-wait-connect-oncall-eng|5|||15)
   -- Accepting a maximum of 5 digits.
   -- Playing '//usr/share/asterisk/sounds/please-wait-connect-oncall-eng'
(language 'en')
   -- User entered '85214'
AGI Tx >> 200 result=0
AGI Rx << get variable my_var
AGI Tx >> 200 result=1 (85214)
AGI Rx << exec saydigits Resource id #1
   -- AGI Script Executing Application: (saydigits) Options: (Resource)
AGI Tx >> 200 result=0
AGI Rx << exec Resource id #1
   -- AGI Script Executing Application: (Resource) Options: (id)
Jan 10 17:31:33 WARNING[4867]: res_agi.c:1147 handle_exec: Could not find
application (Resource)
AGI Tx >> 200 result=-2


I also tried:
$my_var=fwrite(STDOUT,"get variable my_var \n");

But always I get 21 as value.
More tries?

--
Ralph Liebessohn
ICQ: 74835911
Skype: liebessohn
_______________________________________________
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Reply via email to