Php script execution from snom phones or internet browser

Hi. I created a php script that changes the DAY/NIGHT mode at asterisk database.

[code]#!/usr/bin/php -q

<?php exec( "/usr/sbin/asterisk -r -x 'DATABASE GET DAYNIGHT C0'", $response); foreach( $response as $value); $current = split(" ", $value); echo $current[0] . " " . $current[1]; if($current[1] == "DAY") { $current[1]="DAY"; }else{ $current[1]="NIGHT"; } exec( '/usr/local/bin/sipsak -i -M -H 192.168.250.6 -O desktop -B '. $current[1] .'" MODE" -r 5060 -s sip:24@192.168.250.224'); ?> [/code]

If I run it from linux shell it works fine. The problem is that if I run it from snom telephone function keys or windows internet browser I get Unable to connect to to asterisk … etc. This error occures when the line

is executed.

Any ideas?
Thanks.

your asterisk run as root? Your apache is owned by other user&group? Its better if you use ami to connect and execute commands.