Passing Data to for SQL Query
Posted: Sun Aug 14, 2016 1:52 pm
Hi,
I'm having trouble passing an vxml variable into my database using php.
I'm trying to run a query against the database table element: ID.
I'm using the root document method to pass the variable between pages and can confirm the variable is present on the desired page, but I cannot get the variable to pass thru to run a query.
My first page is: root.php
Here is my second page which takes input from plum and places it in a variable <assign name="lookUp" expr="lookUp"/>:
Here's the third page in which I'm trying to pass the variable to php for a query against the DB.
Any insight would be greatly appreciated.
I'm having trouble passing an vxml variable into my database using php.
I'm trying to run a query against the database table element: ID.
I'm using the root document method to pass the variable between pages and can confirm the variable is present on the desired page, but I cannot get the variable to pass thru to run a query.
My first page is: root.php
Code: Select all
<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.0">
<var name="lookUp"/>
<form id="mainmenu">
<field name="menuchoice">
<grammar type="application/x-jsgf" mode="dtmf">
1|0|5
</grammar>
<prompt>
Press 1 to begin the voting process.
Press 0 to hear this message again.
press 5 to hear the telephone number again.
</prompt>
<filled>
<if cond="menuchoice==1">
<goto next="page1.php"/>
<elseif cond="menuchoice==0"/>
<goto next="root.php"/>
<elseif cond="menuchoice==5"/>
617-712-3999 x8723
</if>
</filled>
</field>
</form>
</vxml>
Code: Select all
<?php
header("Content-type: text/xml");
echo "<?xml version=\"1.0\"?>\n";
?>
<vxml version="2.0" application="root.php">
<form>
<field name="lookUp" type="digits?length=5">
<prompt>
Please enter your identification number.
</prompt>
<filled>
<assign name="lookUp" expr="lookUp"/>
<submit next="page2.php" method="post" namelist="lookUp" fetchtimeout="60s"/>
</filled>
<noinput>
<prompt>
Sorry, I didn't hear you.
</prompt>
<reprompt/>
</noinput>
<nomatch>
<prompt>
Sorry, I didn't understand you.
</prompt>
<reprompt/>
</nomatch>
</field>
</form>
</vxml>
Code: Select all
<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
$dbhost='provider';
$dbusername='username';
$dbuserpass='password';
$dbname='dbname';
$dbTable='dbtable';
$myXMLData =
"<?xml version='1.0' encoding='UTF-8'?>
<'lookUp'>";
$sxml = simplexml_load_string($myXMLData);
//print_r($sxml);
$conn = mysql_connect($dbhost, $dbusername, $dbuserpass) or die('Error connecting to mysql'.mysql_error());
mysql_select_db($dbname);
$result = mysql_query("SELECT * FROM dbTable WHERE ID ='$sxml'") or die(mysql_error());
$program_name=mysql_fetch_assoc($result);
mysql_close($conn);
?>
<vxml version="2.0" application="root.php">
<form>
<field name="lookUp" type="digits">
<filled>
Your identification number is: <value expr="lookUp"/>
</filled>
</field>
<var name="program_name" expr="'<?echo($program_name["STATUS"] . ", " . $program_name["FIRSTNAME"]. " " . $program_name["LASTNAME"])?>'" />
<block>
<prompt>This is <value expr="program_name"/>
</prompt>
</block>
</form>
</vxml>