- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
显示一个 fatal error :无法在第 13 行/home/web/public_html/loginfinal/include/database.php 中重新声明类 MySQLDB当我使用下面的代码时。
<?php $site_root = $_SERVER['DOCUMENT_ROOT']; ?>
<?
include("include/session.php");
if(!$session->isVerified() && $session->logged_in){
header("Location: email.php");
}
?>
<html>
<title>Login page</title>
<body>
<?php
include_once($site_root ."/loginfinal/nav_top.php");
?>
<table>
<tr>
<td>
<?
//others detail
?>
读完这个问题后,现在我使用下面的代码,它不显示任何错误,也不显示导航。请问我的问题出在哪里?
<?php $site_root = $_SERVER['DOCUMENT_ROOT']; ?>
<?
include("include/session.php");
if(!$session->isVerified() && $session->logged_in){
header("Location: email.php");
?>
<html>
<title>Login page</title>
<body>
<?php
if(!class_exists('MySQLDB') == true){
include_once($site_root ."/loginfinal/nav_top.php");}
?>
<table>
<tr>
<td>
<?
//others detail
?>
这是我的 Nnav_top.php
<?
include("include/session.php");
include("db.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<META name="TITLE" content="navigation">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta http-equiv='Content-Type' content='text/html; charset=UFT-8'/>
<title>navigation</title>
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/bootstrap-theme.min.css">
<script src="/js/jquery.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
</head>
<body>
<nav role="navigation" class="navbar navbar-inverse">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="container">
<div class="navbar-header">
<button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="#" class="navbar-brand"><img src="image.jpg" width="55" height="40">BD Showbiz</a>
</div>
<!-- Collection of nav links, forms, and other content for toggling -->
<div id="navbarCollapse" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#"><span class="glyphicon glyphicon-home"></span> <br>Home</a></li>
<li><a href="/bd_About%20Us.htm"><span class="glyphicon glyphicon-heart"></span> <br>About Us</a></li>
<li class="dropdown">
<a data-toggle="dropdown" class="dropdown-toggle" href="#"><span class="glyphicon glyphicon-shopping-cart"></span> <br>Service<b class="caret"></b></a>
<ul role="menu" class="dropdown-menu">
<li class="dropdown-submenu"> <a href="#">Event Management</a>
<ul class="dropdown-menu">
<li><a href="/bd_Corporate%20Event.htm">Corporate Event</a></li>
<li><a href="/wedding.htm">Wedding Event</a></li>
<li><a href="/bd_Others%20Event.htm">Others Privet Event</a></li>
</ul>
</li>
<li><a href="/bd_Offer.htm">Special Offer</a></li>
</ul>
</li>
<li class="dropdown">
<a data-toggle="dropdown" class="dropdown-toggle" href="#"><span class="glyphicon glyphicon-th-large"></span> <br>Web Service<b class="caret"></b></a>
</li>
<li><a href="/bd_contact_us.php"><span class="glyphicon glyphicon-map- marker"></span> <br>Contact Us</a></li>
</ul>
<form role="search" class="navbar-form navbar-left" method="get" action="/search.htm"><span class="glyphicon glyphicon-search"></span> <br>
<div class="form-group">
<input type="text" placeholder="Search" id="tfq" class="form-control" name="q">
<input type="hidden" name="sitesearch" value="" />
<input type="hidden" name="sitesearch" value="" checked />
</div>
</form>
<ul class="nav navbar-nav">
<?php
if($session->logged_in){
echo '<a data-toggle="dropdown" class="dropdown-toggle" href="#" id="navLogin"><span class="glyphicon glyphicon-user"></span> <br>'.$session->username.' <b class="caret"></b> </a>';
echo ' <ul role="menu" class="dropdown-menu">';
echo ' <li><a href=/main.php>Profile</a></li>';
echo ' <li><a href=/useredit.php>Setting</a></li>';
echo ' <li class="divider"></li>';
if($session->isAdmin()){
echo '<li><a href=/admin/admin.php>Admin Center</a></li>';
}
echo ' <li><a href=process.php>Logout</a></li>';
echo ' </ul>';
}else{
echo '<a data-toggle="dropdown" class="dropdown-toggle" href="#" id="navLogin"><span class="glyphicon glyphicon-log-in"></span> <br>login <b class="caret"></b></a>';
echo ' <ul role="menu" class="dropdown-menu">';
echo ' <form style="margin: 0px" accept-charset="UTF-8" action="process.php" method="post">';
echo ' </form>';
echo ' </ul>';
}
?>
<li class="divider-vertical"></li>
<?php
global $dbh;
//Check image address
$result2 = mysqli_query($dbh,"SELECT u_imgurl FROM blog_users WHERE username='$session- >username'");
if(!$result2) {
die("Database query failed: " . mysqli_error());
}
$u_imgurl = "";
while ($row = mysqli_fetch_array($result2)) {
$u_imgurl = $row["u_imgurl"];
}
if (empty($u_imgurl)) $u_imgurl = "picture.jpg";
//End Check image address
if($session->logged_in){
echo '<li><img alt="" src="/loginfinal/img/'.$u_imgurl.'" width="40" height="40" class="img-responsive img-circle profile-img"/></li>';
}else{
echo '<li><a href="/loginfinal/register.php"><span class="glyphicon glyphicon-lock"> </span> <br>Sign Up</a></li>';
}
?>
</li>
</ul>
</div>
</div>
</nav>
</body>
</html>
我的数据库.php
<?
/**
* Database.php
*
* The Database class is meant to simplify the task of accessing
* information from the website's database.
*
*
*/
include("constants.php");
class MySQLDB
{
var $connection; //The MySQL database connection
var $num_active_users; //Number of active users viewing site
var $num_active_guests; //Number of active guests viewing site
var $num_members; //Number of signed-up users
/* Note: call getNumMembers() to access $num_members! */
/* Class constructor */
function MySQLDB(){
/* Make connection to database */
$this->connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die(mysql_error());
mysql_select_db(DB_NAME, $this->connection) or die(mysql_error());
/**
* Only query database to find out number of members
* when getNumMembers() is called for the first time,
* until then, default value set.
*/
$this->num_members = -1;
if(TRACK_VISITORS){
/* Calculate number of users at site */
$this->calcNumActiveUsers();
/* Calculate number of guests at site */
$this->calcNumActiveGuests();
}
}
function confirmUserPass($username, $password){
/* Add slashes if necessary (for query) */
if(!get_magic_quotes_gpc()) {
$username = addslashes($username);
}
/* Verify that user is in database */
$q = "SELECT password FROM ".TBL_USERS." WHERE username = '$username'";
$result = mysql_query($q, $this->connection);
if(!$result || (mysql_numrows($result) < 1)){
return 1; //Indicates username failure
}
/* Retrieve password from result, strip slashes */
$dbarray = mysql_fetch_array($result);
$dbarray['password'] = stripslashes($dbarray['password']);
$password = stripslashes($password);
/* Validate that password is correct */
if($password == $dbarray['password']){
return 0; //Success! Username and password confirmed
}
else{
return 2; //Indicates password failure
}
}
function confirmUserID($username, $userid){
/* Add slashes if necessary (for query) */
if(!get_magic_quotes_gpc()) {
$username = addslashes($username);
}
/* Verify that user is in database */
$q = "SELECT userid FROM ".TBL_USERS." WHERE username = '$username'";
$result = mysql_query($q, $this->connection);
if(!$result || (mysql_numrows($result) < 1)){
return 1; //Indicates username failure
}
/* Retrieve userid from result, strip slashes */
$dbarray = mysql_fetch_array($result);
$dbarray['userid'] = stripslashes($dbarray['userid']);
$userid = stripslashes($userid);
/* Validate that userid is correct */
if($userid == $dbarray['userid']){
return 0; //Success! Username and userid confirmed
}
else{
return 2; //Indicates userid invalid
}
}
function usernameTaken($username){
if(!get_magic_quotes_gpc()){
$username = addslashes($username);
}
$q = "SELECT username FROM ".TBL_USERS." WHERE username = '$username'";
$result = mysql_query($q, $this->connection);
return (mysql_numrows($result) > 0);
}
function usernameBanned($username){
if(!get_magic_quotes_gpc()){
$username = addslashes($username);
}
$q = "SELECT username FROM ".TBL_BANNED_USERS." WHERE username = '$username'";
$result = mysql_query($q, $this->connection);
return (mysql_numrows($result) > 0);
}
function addNewUser($username, $password, $email, $emailvcode){
$time = time();
/* If admin sign up, give admin user level */
if(strcasecmp($username, ADMIN_NAME) == 0){
$ulevel = ADMIN_LEVEL;
$verifystatus = 0;
}else{
$ulevel = USER_LEVEL;
$verifystatus = 0;
}
$q = "INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', '0', $ulevel, '$email', '$verifystatus', '$emailvcode', '$time')";
return mysql_query($q, $this->connection);
}
function updateUserField($username, $field, $value){
$q = "UPDATE ".TBL_USERS." SET ".$field." = '$value' WHERE username = '$username'";
return mysql_query($q, $this->connection);
}
function getUserInfo($username){
$q = "SELECT * FROM ".TBL_USERS." WHERE username = '$username'";
$result = mysql_query($q, $this->connection);
/* Error occurred, return given name by default */
if(!$result || (mysql_numrows($result) < 1)){
return NULL;
}
/* Return result array */
$dbarray = mysql_fetch_array($result);
return $dbarray;
}
/**
* retrieve email verification code
*/
function emailVerify($vcode){
$q = "SELECT * FROM ".TBL_USERS." WHERE emailverifier = '$vcode'";
$result = mysql_query($q, $this->connection);
/* Verification code exists, verify user and return true */
if(mysql_num_rows($result) != 0){
$q = "UPDATE ".TBL_USERS." SET verifystatus = '1' WHERE emailverifier = '$vcode'";
$result = mysql_query($q, $this->connection);
return 1;
}
/* verification code doesn't exist return false */
else
{
return 0;
}
}
function getNumMembers(){
if($this->num_members < 0){
$q = "SELECT * FROM ".TBL_USERS;
$result = mysql_query($q, $this->connection);
$this->num_members = mysql_numrows($result);
}
return $this->num_members;
}
function calcNumActiveUsers(){
/* Calculate number of users at site */
$q = "SELECT * FROM ".TBL_ACTIVE_USERS;
$result = mysql_query($q, $this->connection);
$this->num_active_users = mysql_numrows($result);
}
function calcNumActiveGuests(){
/* Calculate number of guests at site */
$q = "SELECT * FROM ".TBL_ACTIVE_GUESTS;
$result = mysql_query($q, $this->connection);
$this->num_active_guests = mysql_numrows($result);
}
function addActiveUser($username, $time){
$q = "UPDATE ".TBL_USERS." SET timestamp = '$time' WHERE username = '$username'";
mysql_query($q, $this->connection);
if(!TRACK_VISITORS) return;
$q = "REPLACE INTO ".TBL_ACTIVE_USERS." VALUES ('$username', '$time')";
mysql_query($q, $this->connection);
$this->calcNumActiveUsers();
}
/* addActiveGuest - Adds guest to active guests table */
function addActiveGuest($ip, $time){
if(!TRACK_VISITORS) return;
$q = "REPLACE INTO ".TBL_ACTIVE_GUESTS." VALUES ('$ip', '$time')";
mysql_query($q, $this->connection);
$this->calcNumActiveGuests();
}
/* These functions are self explanatory, no need for comments */
/* removeActiveUser */
function removeActiveUser($username){
if(!TRACK_VISITORS) return;
$q = "DELETE FROM ".TBL_ACTIVE_USERS." WHERE username = '$username'";
mysql_query($q, $this->connection);
$this->calcNumActiveUsers();
}
/* removeActiveGuest */
function removeActiveGuest($ip){
if(!TRACK_VISITORS) return;
$q = "DELETE FROM ".TBL_ACTIVE_GUESTS." WHERE ip = '$ip'";
mysql_query($q, $this->connection);
$this->calcNumActiveGuests();
}
/* removeInactiveUsers */
function removeInactiveUsers(){
if(!TRACK_VISITORS) return;
$timeout = time()-USER_TIMEOUT*60;
$q = "DELETE FROM ".TBL_ACTIVE_USERS." WHERE timestamp < $timeout";
mysql_query($q, $this->connection);
$this->calcNumActiveUsers();
}
/* removeInactiveGuests */
function removeInactiveGuests(){
if(!TRACK_VISITORS) return;
$timeout = time()-GUEST_TIMEOUT*60;
$q = "DELETE FROM ".TBL_ACTIVE_GUESTS." WHERE timestamp < $timeout";
mysql_query($q, $this->connection);
$this->calcNumActiveGuests();
}
function query($query){
return mysql_query($query, $this->connection);
}
};
$database = new MySQLDB;
?>
最佳答案
它不会显示,因为您正在检查该类是否不存在(事实确实如此),因为它提示它被重新声明(重新创建)。
include
/require
更改为 include_once
/require_once
。这将使文件仅在请求中包含一次,这意味着该类不会重新声明。
关于php - 无法在另一个 php 文件中添加 navigation.php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26118959/
我创建了一个用户可以添加测试的字段。这一切运行顺利我只希望当用户点击(添加另一个测试)然后上一个(添加另一个测试)删除并且这个显示在新字段中。 所有运行良好的唯一问题是点击(添加另一个字段)之前添加另
String[] option = {"Adlawan", "Angeles", "Arreza", "Benenoso", "Bermas", "Brebant
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
我正在努力将 jQuery 滚动功能添加到 nav-tab (Bootstrap 3)。我希望用户能够选择他们想要的选项卡,并在选项卡内容中有一个可以平滑滚动到 anchor 的链接。这是我的代码,可
我正在尝试在用户登录后再添加 2 个 ui 选项卡。首先,我尝试做一个之后。 $('#slideshow').tabs('remove', '4'); $("#slideshow ul li:last
我有一个包含选择元素的表单,我想通过选择添加和删除其中一些元素。这是html代码(这里也有jsfiddle http://jsfiddle.net/txhajy2w/):
正在写这个: view.backgroundColor = UIColor.white.withAlphaComponent(0.9) 等同于: view.backgroundColor = UICo
好的,如果其中有任何信息,我想将这些列添加到一起。所以说我有 账户 1 2 3 . 有 4 个帐户空间,但只有 3 个帐户。我如何创建 java 脚本来添加它。 最佳答案 Live Example H
我想知道是否有一种有效的预制算法来确定一组数字的和/差是否可以等于不同的数字。示例: 5、8、10、2,使用 + 或 - 等于 9。5 - 8 = -3 + 10 = 7 + 2 = 9 如果有一个预
我似乎有一个卡住的 git repo。它卡在所有基本的添加、提交命令上,git push 返回所有内容为最新的。 从其他帖子我已经完成了 git gc 和 git fsck/ 我认为基本的调试步骤是
我的 Oracle SQL 查询如下- Q1- select hca.account_number, hca.attribute3, SUM(rcl.extended_amou
我正在阅读 http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingG
我正在尝试添加一个“加载更多”按钮并限制下面的结果,这样投资组合页面中就不会同时加载 1000 个内容,如下所示:http://typesetdesign.com/portfolio/ 我对 PHP
我遇到这个问题,我添加了 8 个文本框,它工作正常,但是当我添加更多文本框(如 16 个文本框)时,它不会添加最后一个文本框。有人遇到过这个问题吗?提前致谢。 Live Link: JAVASCRIP
add/remove clone first row default not delete 添加/删除克隆第一行默认不删除&并获取正确的SrNo(例如:添加3行并在看到问题后删除SrNo.2)
我编码this ,但删除按钮不起作用。我在控制台中没有任何错误.. var counter = 0; var dataList = document.getElementById('materi
我有一个类似数组的对象: [1:数组[10]、2:数组[2]、3:数组[2]、4:数组[2]、5:数组[3]、6:数组[1]] 我正在尝试删除前两个元素,执行一些操作,然后将它们再次插入到同一位置。
使用的 Delphi 版本:2007 你好, 我有一个 Tecord 数组 TInfo = Record Name : String; Price : Integer; end; var Info
我使用了基本的 gridster 代码,然后我声明了通过按钮添加和删除小部件的函数它工作正常但是当我将调整大小功能添加到上面的代码中时,它都不起作用(我的意思是调整大小,添加和删除小部件) 我的js代
title 323 323 323 title 323 323 323 title 323 323 323 JS $(document).keydown(function(e){
我是一名优秀的程序员,十分优秀!