On 1/10/07, <b class="gmail_sendername">Lee Jenkins</b> &lt;<a href="mailto:lee@datatrakpos.com">lee@datatrakpos.com</a>&gt; 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>&gt; Hi,<br>&gt;<br>&gt; I&#39;m trying to write a AGI in PHP to get the numbers dialed (with<br>&gt; read()), save it into a variable to insert it into a SQL server<br>&gt; database. But I cannot see results into the variable, it always return
<br>&gt; NULL.<br>&gt; Here is a piece of the AGI.<br>&gt;<br>&gt; fwrite(STDOUT,&quot;exec Read my_var|/sound_to_play|5|||15 \n&quot;);<br>&gt; fflush(STDOUT);<br>&gt; $conn=odbc_connect(&#39;MSSQL&#39;, &#39;USER&#39;, &#39;PASS&#39;);
<br>&gt; $query = odbc_exec($conn, &quot;INSERT INTO dialed(number) VALUES(&#39;$my_var&#39;)&quot;);<br>&gt;<br>&gt; Even if I only show my_var value or try to use it inside asterisk, the<br>&gt; value is NULL.<br>&gt; There is another way to do it? Am I doing a mistake here?
<br>&gt; I&#39;m using Asterisk 1.2.13.<br>&gt;<br><br>I&#39;m not a php guy, but aren&#39;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 &quot;my_var&quot;<br><br>fwrite(STDOUT,&quot;exec Read my_var|/sound_to_play|5|||15 \n&quot;);<br><br>// In this part you are constructing your sql statement<br>// with a null value cause you didn&#39;t make a call to
<br>// GET VARIABLE before constructing your sql.<br><br>$query = odbc_exec($conn, &quot;INSERT INTO dialed(number) VALUES(&#39;$my_var&#39;)&quot;);<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 &quot;get variable&quot; returns the value I dialed, but doesn&#39;t give the exact value to it. I got Resource ID #1 instead.
<br>Using:<br>fwrite(STDOUT,&quot;exec read my_var|//usr/share/asterisk/sounds/please-wait-connect-oncall-eng|5|||15 \n&quot;);<br>fwrite(STDOUT,&quot;get variable my_var \n&quot;);<br>fflush(STDOUT);<br>$my_var=STDIN;<br>
fwrite(STDOUT,&quot;exec saydigits $my_var \n&quot;);<br><br>I got it:<br><br><font size="1">AGI Rx &lt;&lt; exec read my_var|//usr/share/asterisk/sounds/please-wait-connect-oncall-eng|5|||15<br>&nbsp;&nbsp;&nbsp; -- AGI Script Executing Application: (read) Options: (my_var|//usr/share/asterisk/sounds/please-wait-connect-oncall-eng|5|||15)
<br>&nbsp;&nbsp;&nbsp; -- Accepting a maximum of 5 digits.<br>&nbsp;&nbsp;&nbsp; -- Playing &#39;//usr/share/asterisk/sounds/please-wait-connect-oncall-eng&#39; (language &#39;en&#39;)<br>&nbsp;&nbsp;&nbsp; -- User entered &#39;85214&#39;<br>AGI Tx &gt;&gt; 200 result=0
<br>AGI Rx &lt;&lt; get variable my_var<br>AGI Tx &gt;&gt; 200 result=1 (85214)<br>AGI Rx &lt;&lt; exec saydigits Resource id #1<br>&nbsp;&nbsp;&nbsp; -- AGI Script Executing Application: (saydigits) Options: (Resource)<br>AGI Tx &gt;&gt; 200 result=0
<br>AGI Rx &lt;&lt; exec Resource id #1<br>&nbsp;&nbsp;&nbsp; -- 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 &gt;&gt; 200 result=-2
<br><br><br clear="all"></font>I also tried:<br>$my_var=fwrite(STDOUT,&quot;get variable my_var \n&quot;);<br><br>But always I get 21 as value.<br>More tries?<br><br>-- <br>Ralph Liebessohn<br>ICQ: 74835911<br>Skype: liebessohn