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

General PHP question

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
uncleunvoid
Posts: 16
Joined: Mon Dec 10, 2007 6:33 am

General PHP question

Post by uncleunvoid »

if I use a php script to run. DOES the vxml have to be able to jump to the php/vxml file. AND/OR DOES the php script I am executing have to contain an xml 'header' ?

I am getting serious errors thrown back at me executing a simple php script. the script executes fine by itself or being called from flash, but errors when called from my xml file.

all examples i found on the forum so far seem to include both php and vxml in the same file in order to execute properly.

Is it possible to just execute php on the side without interfering with the flow of my vxml application?

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

Run php/vxml files as long as IVR script is valid

Post by support »

Hi,

It is possible to run php/vxml files as long as your script has valid VXML within it. And yes, the php/vxml script has to contain an xml 'header'. For an IVR example, note the php embedded in the <var> tags below.

Code: Select all

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

$customerid = 1000;
$age = 15;
?>

<vxml version="2.0">
   <form>
      <var name="customerid" expr="'<?php echo($customerid)?>'"/>
      <var name="age" expr="'<?php echo($age)?>'"/>
      <block>
         <prompt> Your customer identification number is <value expr="customerid"/>. </prompt>
          <prompt> Your age is <value expr="age"/>. </prompt>
      </block>
   </form>
</vxml> 
Finally, yes, it is possible to execute php on the side without interfering with the flow of your vxml application.

If you are still getting IVR errors, feel free to post a snippet of your IVR code and an IVR call log that demonstrates the IVR error.

Regards,
Plum Support
Last edited by support on Fri Feb 19, 2010 12:57 pm, edited 4 times in total.

uncleunvoid
Posts: 16
Joined: Mon Dec 10, 2007 6:33 am

Post by uncleunvoid »

do you have an example how to call a php script without having to leave my initial vxml script?

uncleunvoid
Posts: 16
Joined: Mon Dec 10, 2007 6:33 am

Post by uncleunvoid »

or i should phrase this better, call a script that doesnt need vxml in it.

I tried to expand on some samples on the support website, yet run into en error when I start doing mysql requests (the files are on my server with php and mysql deployed and activated)

Here is the code:

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

$keyCode= $_POST[keyCode];

$dbhost = "localhost:8889/";
$dbuser = "xxxx";
$dbpass = "xxxx";
$dbname = "mydbname";
$dbTable = "tbl_remotes";

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

$query = "SELECT id FROM $dbTable WHERE callerId='$callerId'";
$result = mysql_query($query);

mysql_close($conn);
?>

<vxml version="2.0">
<form>
<var name="keyCode" expr="'<?php echo($keyCode)?>'"/>
<block>
<prompt> You pressed <value expr="keyCode"/></prompt>
</block>
</form>
</vxml>


and i get back

DocumentParser::FetchDocument - Parse error in file "submittest.php", line 2, column 4 - Unknown element 'br'
errno: 205 uri submittest.php
received event: error.badfetch


there is no BR tag in the code

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

View IVR script to see remote error received by browser

Post by support »

Hi,

The IVR error that you are getting:

DocumentParser::FetchDocument - Parse error in file "submittest.php", line 2, column 4 - Unknown element 'br'
errno: 205 uri submittest.php
received event: error.badfetch

indicates that there is server side script error. There is most likely a parse error in the file. In your IVR call log, you should be able to click on “Click here to view saved VoiceXML script”, where you can see the contents of the file returned by your web browser. Remote errors in the server script often generate HTML based error messages. These IVR error messages cannot be parsed by the VoiceXML platform and will result in an error.badfetch. So, by viewing your IVR script, you should be able to view the remote error received by the browser.

Hope this helps solve your error.

Regards,
Plum Support

Post Reply