[Asterisk-Users] Mysql cmd with Asterisk Problems

pbx at itsngroup.com pbx at itsngroup.com
Wed May 18 07:12:13 MST 2005


Hello all:
I am trying to use the mysql command to retrieve information from a mysql
database.
my example here was formed from using the wiki reference to using the
mysql command.

The problem is with the fetch command.
Here is the macro code:
Mysql(QueryString=SELECT\ ivr-password\ from\ users\ where\ ivr-id=${userid})
Mysql(Query r ${connid} ${QueryString})
Mysql(Fetch fetchid ${r} dbuserpass)
Mysql(Clear ${resultid})
Mysql(Disconnect ${connid})

However, it never gets past the fetch line. and ${r} is not showing
anything either from che CLI window.
I usesd the mysqlasteri web page to make the command escape character
happy, etc. I have tried putting \' around each item, etc. However The
same problem comes back with the fetch line. I have tried to use
mysql(fetch fetchid ${r} ivr-password) thinking the variable that is
coming out of the DB has to be named the same, etc. but it doesn't matter.
${r} is blank in the fetch command when I know there is a valid record.
The ${connid} has a value in it as it's being passed.

I have only been able to find the mysql cmd example on the wiki, and no
other. I program mysql with php all the time, but i dont understand the
errors that it is returning..
Thank you.

Output is below:

    -- Executing NoOp("IAX2/4000 at 192.168.1.141:4569-1", "")
    -- Executing NoOp("IAX2/4000 at 192.168.1.141:4569-1", "")
    -- Executing NoOp("IAX2/4000 at 192.168.1.141:4569-1", "Authenticate user
now: userid: 1234 - pass: 0000")
    -- Executing NoOp("IAX2/4000 at 192.168.1.141:4569-1", "Passing to
macro-mmisd-login")
    -- Executing Macro("IAX2/4000 at 192.168.1.141:4569-1",
"mmisd-login|1234|0000")
    -- Executing NoOp("IAX2/4000 at 192.168.1.141:4569-1", "Entered
Macro-mmisd-login")
    -- Executing NoOp("IAX2/4000 at 192.168.1.141:4569-1", "Passed in userid:
1234 - userpass: 0000")
    -- Executing MYSQL("IAX2/4000 at 192.168.1.141:4569-1", "Connect connid
localhost mmisd-ivr-user mmisd-ivr-pass ivr-db")
    -- Executing SetVar("IAX2/4000 at 192.168.1.141:4569-1",
"QueryString=SELECT\ ivr-password\ from\ users\ where\ ivr-id=1234")
    -- Executing MYSQL("IAX2/4000 at 192.168.1.141:4569-1", "Query r 18
SELECT\ ivr-password\ from\ users\ where\ ivr-id=1234")
    -- Executing MYSQL("IAX2/4000 at 192.168.1.141:4569-1", "Fetch fetchid 
dbuserpass")
May 18 07:01:05 WARNING[7114]: app_addon_sql_mysql.c:113 find_identifier:
Identifier 0, identifier_type 2 not found in identifier list
May 18 07:01:05 WARNING[7114]: app_addon_sql_mysql.c:328 aMYSQL_fetch:
aMYSQL_fetch: Invalid result identifier 0 passed





More information about the asterisk-users mailing list