[asterisk-users] MYSQL problem and configuration

Karim H marikounet at hotmail.com
Fri Aug 24 05:32:37 CDT 2007


Hello,I am new to asterisk but i have vbeen scriptinh PHP SQL and webLanguages for a long time.I can Give you a solution but using php AGI:extensions.con-----> AGI(connect.agi);/var/lib/asterisk/agi-bin/connect.agi :#!/usr/bin/php -q<?phpset_time_limit(0);ob_implicit_flush();error_reporting(0);//Initialisation des entrée-sortiefunction init() {#create file handles if neededif(!defined('STDIN')){    define('STDIN',fopen('php://stdin','r'));}if(!defined('STDOUT')){    define('STDOUT',fopen('php://stdout','w'));}if(!defined('STDERR')){    define('STDERR',fopen('php://stderr','w'));}#retrieve all AGI variables from Asteriskwhile(!feof(STDIN)){    $temp=trim(fgets(STDIN,4096));    if(($temp=="")||($temp=="\n"))    {        break;    }    $s=split(":",$temp);    $name=str_replace("agi_","",$s[0]);    $agi[$name]=trim($s[1]);}return $agi;}function checkresult($res){    trim($res);    if(preg_match('/^200/',$res))    {        if(!preg_match('/result=(-?\d+)/',$res,$matches))        {            fwrite(STDERR,"FAIL ($res)\n");            fflush(STDERR);            return0;        } else {            fwrite(STDERR,"PASS (".$matches[1].")\n");            fflush(STDERR);            return $matches[1];        }    } else {        fwrite(STDERR,"FAIL (unexpected result '$res')\n");        fflush(STDERR);        return -1;    }}$agivar = init();$hostname= 'xxxx';
$database= 'xxxxx';
$username= 'xxxxx';
$password= 'xxxx';
$dbprotect = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database, $dbprotect);$result = mysql_query("SELECT * FROM user_table WHERE user_age>12");while($entry = mysql_fetch_array($result)) {fwrite(STERR, "Name : $entry['name'], Age: $entry['age']  \n");fflush(STDOUT);$result = trim(fgets(STDIN,4096));checkresult($result);}?>It will return things on the asterisk CLI.... You can adapt this example for youI don't know if it help but it shows a way to do...Kheraud> From: jp at speakplease.com> To: asterisk-users at lists.digium.com> Date: Fri, 24 Aug 2007 12:56:55 +0300> Subject: [asterisk-users] MYSQL problem and configuration> > Greetings everyone> > I've set up a call recording system on debian 4.0 with asterisk and mysql db> for handling user information (accessible over the net for users). My> asterisk is running on one machine and the mysql on another. The connection> is over lan. Now I have a problem and a question.> > My problem is:> When mysql_real_connect doesn't get connection to the mysql server asterisk> pretty much freezes and doesn't let any info go in or out, even the CLI> freezes. I've seen a bug report on this but no solution(?)> Although this might be a bug with asterisk when I have the connection set to> a hosted mysql server (company that hosts our website during the testing> period) the connection works fine so I've come to conclusion that the> problem might be the mysql and/or debian configuration I have. SO...> > My question is:> How should I configure mysql (and debian box) for asterisk connections?> > Best regards> Jari-Pekka Lehtinen> > > _______________________________________________> --Bandwidth and Colocation Provided by http://www.api-digital.com--> > asterisk-users mailing list> To UNSUBSCRIBE or update options visit:>    http://lists.digium.com/mailman/listinfo/asterisk-users
_________________________________________________________________
Le blog Messenger de Michel, candidat de la Nouvelle Star : analyse, news, coulisses… A découvrir !
http://michel-nouvelle-star2007.spaces.live.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20070824/ce3c99dc/attachment.htm 


More information about the asterisk-users mailing list