We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

Recite the data from MySQL

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
Chris
Posts: 64
Joined: Wed Jul 23, 2008 12:50 pm

Recite the data from MySQL

Post by Chris »

Thank you Tech Support for helping me figure out how to populate our MySQL db,
Now, the obvious next step is I am trying to get a VXML document to recite or play back the data that is in my MySQL db. But all hell breaks loose with errors galore!

I don't get errors from the scratchpad. I only get the errors when calling in, and they are very strange.

Of course I tried my code many different ways and what's below is the simplest. And I tried it as .VXML and .PHP.

When I name the document .VXML I get an error that's kind of unbelieveable, because I don't get the error in other .VXML documents.

XML Parsing Error: not well-formed
Line Number 3, Column 30:
echo("<?xml version=\"1.0\"?>\n");
----------------------------------^

Now, here's another kick in the head.
When I rename the identical document as .PHP
It denies access to a different user of an altogether different db on our server.
The user that's being denied access is not the user indicated in the code!
Below is that error:
XML Parsing Error: junk after document element
Line Number 3, Column 1:
<b>Warning</b>: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Access denied for user 'xxxxxxxxmobi'@'nn.nnn.nnnn.nn' (using password: XX) in <b>GetDataFromMySQL.php</b> on line <b>13</b><br />
^

How can either of these errors occur?
And what's the solution?
Tech Support was successful in helping me get the data into MySQL.
And you have my gratitude. Again.
Now how can we fix these problems so I can present the info in the db to the caller?

Here's the code:

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");

$program_name= $_POST[program_name];

$dbhost='HHHHHHHHHHHHH';
$dbusername='UUUUUUUUUUU';
$dbuserpass='PPPPPPPPPPPPP';
$dbname='NNNNNNNNNNNNNN';
$dbTable='TTTTTTTTTTTTTT';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql'.mysql_error());
mysql_select_db($dbname);

$query = "SELECT program_name FROM $dbTable WHERE trx_agent='MASTER'";
$result = mysql_query($query);

mysql_close($conn);
?>

<vxml version="2.0">
<form>
<var name="program_name" expr=" '<? echo ($program_name) ?>' " />

<block>
<prompt> This is <value expr="program_name"/></prompt>
</block>
</form>
</vxml>
Thanks,
Chris

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR code fix to recite or play back data in MySQL db

Post by support »

Hi,

Looking at your IVR code, we noticed this line:

Code: Select all

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql'.mysql_error()); 
However, $dbuser and $dbpass aren't defined. These should be changed to $dbusername and $dbuserpass.

So, your IVR code should be changed to this:

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");

$program_name= $_POST['program_name'];

$dbhost='HHHHHHHHHHHHH';
$dbusername='UUUUUUUUUUU';
$dbuserpass='PPPPPPPPPPPPP';
$dbname='NNNNNNNNNNNNNN';
$dbTable='TTTTTTTTTTTTTT';

$conn = mysql_connect($dbhost, $dbusername, $dbuserpass) or die('Error connecting to mysql'.mysql_error());
mysql_select_db($dbname);

$query = "SELECT program_name FROM $dbTable WHERE trx_agent='MASTER'";
$result = mysql_query($query);

mysql_close($conn);
?>

<vxml version="2.0">
<form>
<var name="program_name" expr=" '<? echo ($program_name) ?>' " />

<block>
<prompt> This is <value expr="program_name"/></prompt>
</block>
</form>
</vxml>
Regards,
Plum Support
Last edited by support on Thu Feb 18, 2010 4:05 pm, edited 3 times in total.

Chris
Posts: 64
Joined: Wed Jul 23, 2008 12:50 pm

Thanks But

Post by Chris »

Thanks for pointing out my errors in $dbusername, $dbuserpass.
I've fixed them but still get the exact same errors as I stated above.
What can we do?
Thanks,
Chris

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR error directly related to PHP code throwing errors

Post by support »

Chris,

The IVR errors you are receiving are directly related to your PHP code throwing errors. Have you tried looking at the page you are trying to use in a web browser? If your PHP outputs anything between the echoed XML prologue (<?xml version="1.0"?>) and the <vxml> tag you are going to run into parse errors. Please view the page in a web browser. If the error in the output is not obvious you can copy and paste the output in a reply to this message. If the web browser is displaying an XML parse error you can also press ctl-u to view the source code in most web browsers.

Also, as a side note. The line numbers in the IVR errors provided by the Plum IVR platform do not correlate to the lines in your PHP code, but the lines output by your PHP code. You need to look at the output of the PHP to determine what the IVR error is, not the PHP itself.

Regards.
Plum Support
Last edited by support on Thu Feb 18, 2010 4:07 pm, edited 2 times in total.

Chris
Posts: 64
Joined: Wed Jul 23, 2008 12:50 pm

Post by Chris »

Thanks for the response.
But when I copy and paste the code you gave me I get the following error.
Line Number 20, Column 34:
<var name="program_name" expr=" '<? echo ($program_name) ?>' " />
---------------------------------^


I'd appreciate it if you could take another look.
Your Code:

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");

$program_name= $_POST['program_name'];

$dbhost='HHHHHHHHHHHHH';
$dbusername='UUUUUUUUUUU';
$dbuserpass='PPPPPPPPPPPPP';
$dbname='NNNNNNNNNNNNNN';
$dbTable='TTTTTTTTTTTTTT';

$conn = mysql_connect($dbhost, $dbusername, $dbuserpass) or die('Error connecting to mysql'.mysql_error());
mysql_select_db($dbname);

$query = "SELECT program_name FROM $dbTable WHERE trx_agent='MASTER'";
$result = mysql_query($query);

mysql_close($conn);
?>

<vxml version="2.0">
<form>
<var name="program_name" expr=" '<? echo ($program_name) ?>' " />

<block>
<prompt> This is <value expr="program_name"/></prompt>
</block>
</form>
</vxml>
Thanks,
Chris

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR developers need more info to debug issue

Post by support »

Hi Chris,

Could you provide us with more context from your IVR call log? The line you provided doesn't give us enough information to help you debug this IVR issue.

Regards,
Plum Support
Last edited by support on Thu Feb 18, 2010 4:07 pm, edited 2 times in total.

Chris
Posts: 64
Joined: Wed Jul 23, 2008 12:50 pm

IS THIS THE INFO YOU NEED?

Post by Chris »

Okay, this is what I get from the Call Log. I hope it's what you are looking for.

Mon 28 Jul 2008 12:38:49 PM EDT:
Call Start Event: ANII DNIS 5734 VURL http://www.PHARMACALL.mobi/VXML/INBOUND ... ent-M.vxml
DocumentParser::FetchDocument()
DocumentParser::FetchDocument(http://www.PHARMACALL.mobi/VXML/INBOUND ... ent-M.vxml)
Cache Miss: http://www.PHARMACALL.mobi/VXML/INBOUND ... ent-M.vxml
Attempting to fetch http://www.PHARMACALL.mobi/VXML/INBOUND ... ent-M.vxml

Mon 28 Jul 2008 12:38:50 PM EDT:
Click here to view saved VoiceXML script
DocumentParser::FetchDocument - Parse error in file "http://www.PHARMACALL.mobi/VXML/INBOUND ... ent-M.vxml", line 20, column 35 - A '<' character cannot be used in attribute 'expr', except through <
errno: 205 uri http://www.PHARMACALL.mobi/VXML/INBOUND ... ent-M.vxml
bargein set to true
INPUTMODES set to "DTMF VOICE"
Audio segment added to prompt queue from TTS application/synthesis+ssml for:
---------
<?xml version='1.0'?><speak>
A serious error of type </speak>
---------
bargein set to true
INPUTMODES set to "DTMF VOICE"
Audio segment added to prompt queue from TTS application/synthesis+ssml for:
---------
<?xml version='1.0'?><speak>error.badfetch</speak>
---------
bargein set to true
INPUTMODES set to "DTMF VOICE"
Audio segment added to prompt queue from TTS application/synthesis+ssml for:
---------
<?xml version='1.0'?><speak> has occurred. Exiting. </speak>
---------
VXI::exit_element()
Newly queued prompts are now being played

Mon 28 Jul 2008 12:38:55 PM EDT:
Call End Event
Ending session
Ending Session On Channel 0
Thanks,
Chris

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR issue stems from improper naming of file

Post by support »

Hi Chris,

The reason why you are getting this IVR error is because the parser doesn't recognize "'<? echo ($program_name) ?>'" since it is in a .vxml file. You have to change your file to a .php file.

Regards,
Plum Support
Last edited by support on Sun Dec 27, 2009 4:55 pm, edited 1 time in total.

Chris
Posts: 64
Joined: Wed Jul 23, 2008 12:50 pm

Silence

Post by Chris »

Okay, so i renamed the file as .php
Guess what?
It doesn't echo anything.
Silence is what I get after "This is..."

<vxml version="2.0">
<form>
<var name="program_name" expr=" '<? echo ($program_name) ?>' " />

<block>
<prompt> This is <value expr="program_name"/></prompt>
</block>
</form>
</vxml>
Thanks,
Chris

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR developer needs more info to debug issue

Post by support »

Hi Chris,

Have you tried looking at the page you are trying to use in a web browser? This will let you know if $program_name is actually being returned by the IVR system.

Regards,
Plum Support
Last edited by support on Sun Dec 27, 2009 4:57 pm, edited 1 time in total.

Chris
Posts: 64
Joined: Wed Jul 23, 2008 12:50 pm

Post by Chris »

Yes, I opened it in a web browser and it returns:


<vxml version="2.0">

<form>
<var name="program_name" expr=" '' "/>

<block>

<prompt>
This is
<value expr="program_name"/>
</prompt>
</block>
</form>
</vxml>


When I drag the file from the desktop onto a web browser it returns:
This is

This is the code I'm using:

Code: Select all

<?php
header("Content-type: text/xml");

$dbhost='HHHHHHHHHHHHH';
$dbusername='UUUUUUUUUUU';
$dbuserpass='PPPPPPPPPPPPP';
$dbname='NNNNNNNNNN';
$dbTable='web_enrollment';

$conn = mysql_connect($dbhost, $dbusername, $dbuserpass) or die('Error connecting to mysql'.mysql_error());
mysql_select_db($dbname);

$query = "SELECT program_name FROM web_enrollment WHERE trx_agent='MASTER' ";
$result = mysql_query($query);
mysql_close($conn);
?>

<vxml version="2.0">
<form>
<var name="program_name" expr=" '<? echo ($program_name) ?>' " />

<block>
<prompt> This is <value expr="program_name"/></prompt>
</block>
</form>
</vxml>
Thanks,
Chris

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Strings must be defined for IVR system to work

Post by support »

Hi Chris,

Looking through your IVR code, where is $program_name defined? This may explain why nothing is being returned for it.

Regards,
Plum Support

Post Reply