我的数据库中存储了一个布尔(位)值。问题是当我在本地服务器上运行PHP脚本时,我得到0或1的值,具体取决于使用mySQL查询针对id存储在Database中的值。但是,在活动服务器上的相同脚本绝对不返回0和1.我的变量保持为空。任何可能的解释。 $ status的值在实时服务器上保持为空,但适用于本地
<?php
session_start();
require_once __DIR__ . '/connect.php';
if (!$_SESSION['loginadmin'])
{
header("location:error.php");
}
else
{
?>
<!DOCTYPE html>
<!---->
<html lang="en">
<head>
<title></title>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,400,300,600,700' rel='stylesheet' type='text/css'>
<link href="bootstrapTheme.css" rel="stylesheet">
<!-- Owl Carousel Assets -->
<link href="owl.carousel.css" rel="stylesheet">
<link rel="stylesheet" href="css/reset.css" type="text/css" media="all">
<link rel="stylesheet" href="css/layout.css" type="text/css" media="all">
<link rel="stylesheet" href="css/style.css" type="text/css" media="all">
<script src="js/Forum_400.font.js"></script>
<script src="js/script.js"></script>
<!--Login Button scripts-->
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
<script src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/megamenu.js"></script>
<script src="js/menu_jquery.js"></script>
<!--**********-->
</head>
<body id="page1">
<div class="body6">
<div class="body1">
<div class="body5">
<div class="main">
<!-- header -->
<header>
<h1><a href="index.php" ><div id="logo"><img src="images/logo.png" / ></div></a></h1>
<nav>
<ul id="top_nav">
<li><a href="index.php"><img src="images/icon_1.gif" alt="">HOME</a></li>
<li class="login" >
<div id="loginContainer"><a href="signout.php"><img src="images/icon_2.png" alt=""><span>SIGN OUT</span></a>
</div>
</li>
<li class="end"><a href="contact.html"><img src="images/icon_3.gif" alt="">CONTACT US</a></li>
</ul>
</nav>
</header>
<!---->
<div class="contact-bg">
<div class="container">
<div class="contact-us">
<div class="contact_right">
<div class="contact-form">
<h3 class="style">ADMINISTRATOR PANEL</h3>
<form method="post" action="status.php">
<div>
<span><label>Membership ID</label></span>
<span><input name="membership" type="text" class="textbox"></span>
</div>
<div>
<input name="submit" type="submit" value="Check">
</div>
<?php
if(isset($_POST['submit']))
{
$_SESSION['id']=$_POST['membership'];
$membership=$_POST['membership'];
$first_id=0;
if(($membership=="" && $membership==NULL))
{
echo "<script type='text/javascript'>alert('We are sorry ! But you have missed the field');</script>";
}
else
{
$query0 = "LOCK TABLES card WRITE";
$result0 = mysql_query($query0);
$query1 = "LOCK TABLES card as card1 READ";
$result1 = mysql_query($query0);
if( $result0 && $result1 )
{
$query = "SELECT status FROM card WHERE id='$membership'";
$result = mysql_query($query);
$numberofrows = mysql_num_rows ($result);
$query_ = "UNLOCK TABLES";
mysql_query($query_);
if($numberofrows)
{
$row=mysql_fetch_row($result,MYSQL_ASSOC);
$status = $row['status'];
$sql = "SELECT name FROM customers WHERE mem_id='$membership'";
$res = mysql_query($sql);
$numberofrows = mysql_num_rows($res);
if (!$status)
{
?>
<div>
<?php
if ($numberofrows)
{
$row=mysql_fetch_row($res,MYSQL_ASSOC);
$memname = $row['name'];
echo "<span><label>Name: $memname $status</label></span>";
}
else
echo "<span><label>No User Against this Membership ID</label></span>";
?>
<span><label>Current Status: Not Activated</label></span>
</div>
<div>
<input type="submit" name="activate" value="Activate">
</div>
<?php
}
else
{
?>
<div>
<?php if ($numberofrows)
{
$row=mysql_fetch_row($res,MYSQL_ASSOC);
$memname = $row['name'];
echo "<span><label>Name: $memname $status</label></span>";
}
else
echo "<span><label>No User Against this Membership ID</label></span>";
?>
</div>
<div>
<span><label>Current Status: Activated </label></span>
<input type="submit" name="deactivate" value="Deactivate">
</div>
<?php
}
}
else
echo "<script type='text/javascript'>alert('No such membership id');</script>";
$query_ = "UNLOCK TABLES";
mysql_query($query_);
}
else
die ("Database access failed: " . mysql_error());
}
// }
}
if(isset($_POST['activate']))
{
$query="UPDATE card SET status=TRUE WHERE id='$_SESSION[id]'";
$result = mysql_query($query);
if($result)
echo "<script type='text/javascript'>alert('membership id: $_SESSION[id] Status Changed to ACTIVATED');</script>";
}
if(isset($_POST['deactivate']))
{
$query="UPDATE card SET status=FALSE WHERE id='$_SESSION[id]'";
$result = mysql_query($query);
if($result)
echo "<script type='text/javascript'>alert('membership id: $_SESSION[id] Status Changed to Deactivated');</script>";
}
}
?>
</form>
</div>
</div>
<div class="clear"></div>
</div>
</div>
</div>
<!---->
<footer>
<div id="wrapper">
<section class="col1 pad_left1">
<div id="end">
<div id="end_menu">
<a href="index.php"> Home </a> . <a href="#">About</a> . <a href="#">Contact</a> . <a href="#">Terms of Use</a> . <a href="#">Sponsors</a>
</div>
<div id="social">
<ul id="icons">
<li><a href="#" class="normaltip"><img src="images/icon1.gif" alt=""></a></li>
<li><a href="#" class="normaltip"><img src="images/icon2.gif" alt=""></a></li>
<li><a href="#" class="normaltip"><img src="images/icon3.gif" alt=""></a></li>
<li><a href="#" class="normaltip"><img src="images/icon4.gif" alt=""></a></li>
<li><a href="#" class="normaltip"><img src="images/icon5.gif" alt=""></a></li>
</ul>
</div>
<div id="sponsors">
<img src="images/g1.png" width="150px" height="100px"/>
<img src="images/g2.png" width="150px" height="100px"/>
</div>
<div id="subscribe">
<span class="toto">NEWSLETTER</span><br>
<input type="text" id="inputs" placeholder="e-mail" />
<br>
<div id="sub_but">
SUBSCRIBE
</div>
</div>
</div>
</section>
</div>
</footer>
</body>
</html>
答案 0 :(得分:1)
我的本地服务器上的状态值为BIT,但在本地服务器上工作正常,但它在实时服务器上返回空。 FIX ON LIVE SERVER:在实时服务器上将状态列类型从BIT更改为TINYINT。