On 1/10/07, <b class="gmail_sendername">Lee Jenkins</b> <<a href="mailto:lee@datatrakpos.com">lee@datatrakpos.com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Ralph Liebessohn wrote:<br>> Hi,<br>><br>> I'm trying to write a AGI in PHP to get the numbers dialed (with<br>> read()), save it into a variable to insert it into a SQL server<br>> database. But I cannot see results into the variable, it always return
<br>> NULL.<br>> Here is a piece of the AGI.<br>><br>> fwrite(STDOUT,"exec Read my_var|/sound_to_play|5|||15 \n");<br>> fflush(STDOUT);<br>> $conn=odbc_connect('MSSQL', 'USER', 'PASS');
<br>> $query = odbc_exec($conn, "INSERT INTO dialed(number) VALUES('$my_var')");<br>><br>> Even if I only show my_var value or try to use it inside asterisk, the<br>> value is NULL.<br>> There is another way to do it? Am I doing a mistake here?
<br>> I'm using Asterisk 1.2.13.<br>><br><br>I'm not a php guy, but aren't we missing the part that retrieves the<br>value saved into my_var from the call to READ?<br><br>// In this part you run the read command and asterisk
<br>// stores the value into the channel variable "my_var"<br><br>fwrite(STDOUT,"exec Read my_var|/sound_to_play|5|||15 \n");<br><br>// In this part you are constructing your sql statement<br>// with a null value cause you didn't make a call to
<br>// GET VARIABLE before constructing your sql.<br><br>$query = odbc_exec($conn, "INSERT INTO dialed(number) VALUES('$my_var')");<br><br>--<br><br>Warm Regards,<br><br>Lee</blockquote></div><br><br>Hi Lee,
<br><br>thanks for the tip. I tried other methods trying to get the variable value, but no success.<br>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.
<br>Using:<br>fwrite(STDOUT,"exec read my_var|//usr/share/asterisk/sounds/please-wait-connect-oncall-eng|5|||15 \n");<br>fwrite(STDOUT,"get variable my_var \n");<br>fflush(STDOUT);<br>$my_var=STDIN;<br>
fwrite(STDOUT,"exec saydigits $my_var \n");<br><br>I got it:<br><br><font size="1">AGI Rx << exec read my_var|//usr/share/asterisk/sounds/please-wait-connect-oncall-eng|5|||15<br> -- AGI Script Executing Application: (read) Options: (my_var|//usr/share/asterisk/sounds/please-wait-connect-oncall-eng|5|||15)
<br> -- Accepting a maximum of 5 digits.<br> -- Playing '//usr/share/asterisk/sounds/please-wait-connect-oncall-eng' (language 'en')<br> -- User entered '85214'<br>AGI Tx >> 200 result=0
<br>AGI Rx << get variable my_var<br>AGI Tx >> 200 result=1 (85214)<br>AGI Rx << exec saydigits Resource id #1<br> -- AGI Script Executing Application: (saydigits) Options: (Resource)<br>AGI Tx >> 200 result=0
<br>AGI Rx << exec Resource id #1<br> -- AGI Script Executing Application: (Resource) Options: (id)<br>Jan 10 17:31:33 WARNING[4867]: res_agi.c:1147 handle_exec: Could not find application (Resource)<br>AGI Tx >> 200 result=-2
<br><br><br clear="all"></font>I also tried:<br>$my_var=fwrite(STDOUT,"get variable my_var \n");<br><br>But always I get 21 as value.<br>More tries?<br><br>-- <br>Ralph Liebessohn<br>ICQ: 74835911<br>Skype: liebessohn