无法回显数据库项

时间:2015-07-11 09:41:36

标签: php mysql

我试图在php中回显一些数据库项目,但似乎没有出现。需要初始化的php会调出database.php来存储所有配置,如下所示。我做错了什么?

SQL语句:

<?php
require_once("includes/initialize.php");

$userName = $_POST["name"];
$userEmail = $_POST["email"];

$sqlName = "SELECT name FROM individual";
$sqlEmail = "SELECT email FROM individual";

if ($sqlEmail == $userEmail || $sqlName == $userName){

$message = "Hi " + $userName + "this is your new password.";

echo $message;

}

?>

数据库配置位于另一个名为database.php的php文件中。

database.php中:

<?php

require_once ("config.php");

 class MySQLDatabase {

private $connection;

function __construct() {
    $this->connection = mysqli_connect(DB_SERVER, DB_USER, DB_PASS, DB_NAME) or die
                    ("Database connection failed: " .
                    mysqli_connect_error() .
                    " (" . mysqli_connect_errno() . ")"
    );
    $db_select = mysqli_select_db($this->connection, DB_NAME);
}

public function close_connection() {
    if (isset($this->connection)) {
        mysqli_close($this->connnection);
        unset($this->connection);
    }
}

public function query($sql) {
    $result = mysqli_query($this->connection, $sql);
    $this->confirm_query($result);
    return $result;
}

private function confirm_query($result) {
    if (!$result) {
        die("Database query failed.");
    }
}

public function escape_value($string) {

    $escaped_string = mysqli_real_escape_string($this->connection, $string);
    return $escaped_string;
}

public function fetch_array($id){
    if (mysqli_fetch_array($id)) {
        return true;
    } 
    }
    }

    $database = new MySQLDatabase();
    $db = & $database;
    ?>

1 个答案:

答案 0 :(得分:0)

您没有运行查询.. ..或获得结果..

$(function() {
var doubleClicked = false;
$(document).on("contextmenu", function (e) {
if(doubleClicked == false) {
e.preventDefault(); // To prevent the default context menu.
var windowHeight = $(window).height()/2;
var windowWidth = $(window).width()/2;
if(e.clientY > windowHeight && e.clientX <= windowWidth) {
  $("#contextMenuContainer").css("left", e.clientX);
  $("#contextMenuContainer").css("bottom", $(window).height()-e.clientY);
  $("#contextMenuContainer").css("right", "auto");
  $("#contextMenuContainer").css("top", "auto");
} else if(e.clientY > windowHeight && e.clientX > windowWidth) {
  $("#contextMenuContainer").css("right", $(window).width()-e.clientX);
  $("#contextMenuContainer").css("bottom", $(window).height()-e.clientY);
  $("#contextMenuContainer").css("left", "auto");
  $("#contextMenuContainer").css("top", "auto");
} else if(e.clientY <= windowHeight && e.clientX <= windowWidth) {
  $("#contextMenuContainer").css("left", e.clientX);
  $("#contextMenuContainer").css("top", e.clientY);
  $("#contextMenuContainer").css("right", "auto");
  $("#contextMenuContainer").css("bottom", "auto");
} else {
  $("#contextMenuContainer").css("right", $(window).width()-e.clientX);
  $("#contextMenuContainer").css("top", e.clientY);
  $("#contextMenuContainer").css("left", "auto");
  $("#contextMenuContainer").css("bottom", "auto");
}
 $("#contextMenuContainer").fadeIn(500, FocusContextOut());
  doubleClicked = true;
} else {
  e.preventDefault();
  doubleClicked = false;
  $("#contextMenuContainer").fadeOut(500);
}
});
function FocusContextOut() {
 $(document).on("click", function () {
   doubleClicked = false; 
   $("#contextMenuContainer").fadeOut(500);
   $(document).off("click");           
 });
}
});

希望这会有所帮助..