AGI Asterisk Code

Dear Friends;
i was wondering if you could check my code blow out to see what is my problem on this agi:
this code is used to get mobile number from users on phone and save it to the database
DB: mobile
TABLE: user_mobile

but it doesn’t work…
whats wrong with this code!!!

This a pretty simple task, what exactly are you trying to do? Can you please explain me your scenario with more details ?

  1. user call
  2. enter mobile number
  3. press #
  4. Save the number to Database
  5. Hangup

Correct your script by following code

$con=mysqli_connect(‘localhost’,‘root’,‘12*****3’)

mysqli_query($con,“INSERT INTO user_mobile (mobile) VALUES ($mobile[‘result’])”);

Check the user entered mobile number by print

echo $mobile[‘result’];

Cheers

Ketan

still not working…

    -- Executing [700@office:1] Answer("SIP/persamizban-0000002d", "") in new stack
       > 0x7f34f4147eb0 -- Probation passed - setting RTP source address to ********:8000
    -- Executing [700@office:2] Wait("SIP/persamizban-0000002d", "1") in new stack
    -- Executing [700@office:3] AGI("SIP/persamizban-0000002d", "mobile.php") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/mobile.php
    -- <SIP/persamizban-0000002d>AGI Script mobile.php completed, returning 0
    -- Executing [700@office:4] Hangup("SIP/persamizban-0000002d", "") in new stack
  == Spawn extension (office, 700, 4) exited non-zero on 'SIP/persamizban-0000002d'

You need to re-write your code. and split your code into blocks.
Then start testing block by block

You need to do 2 things.

  1. switch on the agi debug. command is
    agi set debug on

  2. Add the below lines in your agi script. and then send us the output of the asterisk console.

     fwrite(STDOUT, "SET VARIABLE mobile $mobile \n");
     fgets(STDIN);

EXCUSE ME BUT I DIDN’T GET WHAT EXACTLY YOU MEAN!