public function getValue()
 {
     require "mysql_util.php";
     if (isset($operandValue)) {
         return $operandValue;
     }
     $mysqli = MySql::getConnection();
     $questionID = trim($operandString, "[]");
     $mysql_value = $mysqli->query("SELECT `Response` FROM Questions WHERE `ID` = '{$questionID}'");
     if (!$mysql_value) {
         throw new Exception("There was a MySQL error: {$mysqli->error}");
         return false;
     }
     $mysql_value = mysqli_fetch_assoc($mysql_value);
     return $mysql_value['Response'];
 }
Ejemplo n.º 2
0
 /**
  * @expectedException \MiniOrm\DbalException
  */
 public function testGetInvalidConnection()
 {
     $oConfig = Configuration::getInstance();
     $oConfig->read(__DIR__ . self::TEST_EMPTY_CONFIG);
     $this->object->getConnection($oConfig);
 }
<?php

require "mysql.php";
$mysqli = MySql::getConnection();
$user_message = "";
if (isset($_POST['submit'])) {
    $customerID = $_POST['customer'];
    $itemsSold = $_POST['item'];
    $quantitySold = $_POST['quantity'];
    $sql = "";
    foreach ($itemsSold as $key => $itemNumber) {
        $quantity = $quantitySold[$key];
        $sql .= "INSERT INTO Sales (`CustomerID`, `ItemNumber`, `Quantity`, `Date`) VALUES ('{$customerID}', '{$itemNumber}', '{$quantity}', now());";
    }
    if ($sql != "") {
        $sale = $mysqli->multi_query($sql);
        if (!$sale) {
            trigger_error("Could not save the sale. Error: {$mysqli->error}");
        } else {
            $user_message = "Thank you. Your sale has been recorded.";
            do {
                $mysqli->use_result();
            } while ($mysqli->next_result());
        }
    }
}
?>
<!DOCTYPE html>

<html lang="en">
<head>