AMI dialplan & MYSQL

hi
I would like to call customers and have confirmation for apointment.
This is wher I’m:
PHP page:
require (“incmanager.php”);
$tocall = $_GET[‘tocall’];
fputs($socket, “Action: Originate\r\n”);
fputs($socket, “Channel: SIP/sip-provider/$tocall\r\n”);
fputs($socket, “Context: test\r\n”);
fputs($socket, “Exten: 40\r\n”);
fputs($socket, “Priority: 1\r\n\r\n”);

ok this page call a phone number and send it to exten 40 in dialplan context “test”
[test]
exten => _4X,1,Dial(sip/${EXTEN})
exten => _4X,2,Hangup()
exten => 40,1,MYSQL(Connect connid localhost user password asterisk)
Exten => 40,2,Answer
Exten => 40,2,SetMusicOnHold(default)
Exten => 40,3,Set(TIMEOUT(digit)=5)
Exten => 40,4,Set(TIMEOUT(answer)=10)
Exten => 40,5,Background(rdv)
Exten => 1,1,MYSQL(Query resultid ${connid} INSERT\ INTO\ rdv\ SET\ conf=0\ WHERE\ tel=${tocall})
Exten => 1,2,Playback(thanks)
Exten => 2,1,MYSQL(Query resultid ${connid} INSERT\ INTO\ rdv\ SET\ conf=0\ WHERE\ tel=${tocall})
Exten => 2,2,Playback(thanks)
exten => 40,6,MYSQL(Clear ${resultid})
exten => 40,7,MYSQL(Disconnect ${connid})

All is working fine exept that the var $tocall is unknown in the dialplan
in fact $tocall is the phone number who is calling the ext 40
how I can get it as $var in the dialplan ?

Thanks

I have tried as whell tel={$CALLERID(num)} and it return MYSQL syntax error