DeadAgi and PHP no working

Hi to all.

I’ve been trying to record to mysql using DeadAgi and php,

the process look like ok, but nothing is recording in the table, but if i do the same process calling the php file from address bar record are copyed to the table:

– Executing [[email protected]:1] DeadAGI(“SIP/327-095128c0”, “RToDb.php”) in new stack
– Launched AGI Script /var/lib/asterisk/agi-bin/RToDb.php
– AGI Script RToDb.php completed, returning 0

My php for deadAgi:
#!/usr/bin/php -q
$db=new database(“mysql”,“localhost”,“drc1”,“root”,“area22”);

		$app_config['debug'] = 0;
		if ($app_config['debug']) {
		// sets SQL statement and then query
		$sql2=("INSERT INTO cdr(uniqueid  ,callerid) VALUES('001','Call From me')");

this code work fine if I do it from address bar on explorer, but not from asterisk dial plan