In article <[EMAIL PROTECTED]>,
Robert Howard <[EMAIL PROTECTED]> wrote:
> I am trying to use the MYSQL command to insert a
> record into a database and I can't seem to get it to
> work. I can do an UPDATE with no problem.
> Here is the line in my dialplan
> exten => s,12,MYSQL(QUERY resultid ${connid} INSERT
> INTO `member` ( `id` , `member_num` , `active` )VALUES
> ('',${number}' , '1'))
> 
> Does anyone have an example of an INSERT INTO that I
> could look at?

Firstly, backticks around table and column names are not needed unless
the name has weird characters in it.

Secondly, the whole query needs single quotes around it.

Thirdly, single quotes within the query need \-escaping.

Here's a working example which updates a database on hangup:

exten => h,1,MYSQL(Connect conn localhost username password dbname)
exten => h,2,MYSQL(Query res ${conn} 'INSERT INTO 
responses(adv_id,resp_callerid,resp_file,resp_created) 
VALUES(${advertid},\'${CALLERIDNUM}\',\'${RECORDED_FILE}\',NOW())')
exten => h,3,MYSQL(Disconnect ${conn})

Hope this helps!
Cheers
Tony
-- 
Tony Mountifield
Work: [EMAIL PROTECTED] - http://www.softins.co.uk
Play: [EMAIL PROTECTED] - http://tony.mountifield.org
_______________________________________________
Asterisk-Users mailing list
[email protected]
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Reply via email to