I'm writing an webpage that calls three telephone numbers and asks what kind of pizza you want. Cheese, Pepperoni, Sausage, or other. Everything is going fine. After the user makes the choice with the telephone keypad I am trying to enter that data into a mysql table. The application errors out, I don't see any output because it says on the phone an application error has occurred.
Here's my code.
Is there something wrong with my php/mysql syntax at the if statement?
Here's my code.
Code:
<?php
// Connect to MySQL, and connect to the Database
mysql_connect('localhost', 'admin', 'admin') or die(mysql_error());
mysql_select_db('poll') or die(mysql_error());
// @start snippet
// Check if values have been entered
$digit = isset($_REQUEST['Digits']) ? $_REQUEST['Digits'] : null;
$choices = array(
'1' => 'Cheese',
'2' => 'Pepperoni',
'3' => 'Sausage',
'4' => 'Pineapple_Bacon',
);
if (isset($choices[$digit])) {
mysql_query("INSERT INTO `results` (`" . $choices[$digit] . "`) VALUES ('1')");
$say = 'Thank you. Your choice has been tallied.';
} else {
$say = "Sorry, I don't have that topping.";
}
// @end snippet
// @start snippet
$response = new Services_Twilio_Twiml();
$response->say($say);
$response->hangup();
header('Content-Type: text/xml');
print $response;
// @end snippet
?>
Is there something wrong with my php/mysql syntax at the if statement?