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
#!/usr/bin/php -q
<?php
require('phpagi.php');
error_reporting(E_ALL);
$agi = new AGI();
$agi->answer();
if(!mysql_connect('localhost','root','12*****3'))
die('Cannot Connect to Database '.mysql_error());
if(!mysql_select_db('mobile'))
die('Cannot Select Database');
$mobile = $agi -> get_data('beep',9000,11);
$result = mysql_query('insert into user_mobile (mobile) values('$mobile');
if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
}
while ($mobile = mysql_fetch_assoc($result)) {
// echo $mobile["mobile"];
$agi->say_digits($mobile["mobile"]);
}
mysql_close();
?>
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 ?
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
EXCUSE ME BUT I DIDN’T GET WHAT EXACTLY YOU MEAN!