title: Asterisk AGI and Mysql string variabile
body: <p>I can not solve a problem, The purpose of the script is to identify the context number.</p>
  
  <p>Below is the asterisk dial plan extensions.conf</p>
  
  <pre><code>exten =&gt; 1234,1,Answer()
  same =&gt; n,Set(NUM2CALL=Hello, your number is eight)
  same =&gt; n,NOOP(${NUM2CALL})
  same =&gt; n,AGI(test.php,${NUM2CALL})
  </code></pre>
  
  <p>The file that is running test.php</p>
  
  <pre><code>#!/usr/bin/php -q
  &lt;?php
  require '/var/lib/asterisk/agi-bin/phpagi/phpagi.php';
  $agi = new AGI();
  
  //DB connect
  $mysqli = new mysqli('127.0.0.1', 'root', 'testdatabase', 'asterisk');
  
  if (mysqli_connect_errno())
  {
      printf("Connect failed: %s\n", mysqli_connect_error());
  
      exit();
  }
  //End
  
  $query  = "SELECT text, number FROM recognation_2";
  $result = $mysqli-&gt;query($query);
  
  while ($row = $result-&gt;fetch_object())
  {
      if(strpos($argv[1], $row-&gt;text) !== FALSE)
      {
          echo $row-&gt;number;
      }
  }
  
  
  ?&gt;
  </code></pre>