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. Thank you all. -- Ralph Liebessohn ICQ: 74835911 Skype: liebessohn -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20070110/d53d8af3/attachment.htm
you could use one of the AGI libraries... then you can just call a function to get the number. AF. 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. > > Thank you all. > > -- > 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
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