0

I have a boolean ( bit ) value stored in my database. The problem is when I run the PHP script on local server I get the value either 0 or 1 depending upon the value stored in Database against the id using mySQL query. However the same script on live server returns absolutely nothing neither 0 nor 1. My variable remains empty. Any possible explanation. The value of $status remains empty on live server but works on local

    <?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>
11
  • 1
    Take a look atthe php error log (file) on that server. Could be for example a start-up error -> your script hasn't been executed at all Commented Feb 5, 2015 at 14:43
  • The script executes and it straight away goes into the ELSE part since the corresponding IF part is dependent on the boolean value. Commented Feb 5, 2015 at 14:51
  • And the query also runs successfully because the script only runs the rest code if the query is executed successfully. Then again I am not able to get why it is working fine on local server and not on live server Commented Feb 5, 2015 at 14:55
  • That's kinda inconsistent with your above statement however the same script on live server returns absolutely nothing neither 0 nor 1. Commented Feb 5, 2015 at 14:59
  • That is the inconsistency I am trying to figure out !! I get values on local server but I dont get any value when I am on live server. Commented Feb 5, 2015 at 15:03

1 Answer 1

1

I had the status value as BIT on my local server which was working fine on the local server however it was returning empty on live server. FIX ON LIVE SERVER: Changed the status column type from BIT to TINYINT on live server.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.