Page 1 of 1

Recite the data from MySQL

Posted: Thu Jul 24, 2008 4:27 pm
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>

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

Posted: Thu Jul 24, 2008 5:22 pm
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

Thanks But

Posted: Thu Jul 24, 2008 5:39 pm
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?

IVR error directly related to PHP code throwing errors

Posted: Fri Jul 25, 2008 10:06 am
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

Posted: Mon Jul 28, 2008 11:46 am
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>

IVR developers need more info to debug issue

Posted: Mon Jul 28, 2008 2:12 pm
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

IS THIS THE INFO YOU NEED?

Posted: Mon Jul 28, 2008 2:29 pm
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

IVR issue stems from improper naming of file

Posted: Mon Jul 28, 2008 2:42 pm
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

Silence

Posted: Mon Jul 28, 2008 7:44 pm
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>

IVR developer needs more info to debug issue

Posted: Tue Jul 29, 2008 8:52 am
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

Posted: Tue Jul 29, 2008 10:04 am
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>

Strings must be defined for IVR system to work

Posted: Mon Aug 04, 2008 9:00 am
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