0

Hi all, i have a problem when my system is not workable if running on the server, but at local host it run as usual without error.. when i want to insert the data it show "Data Not Inserted". Why it happen?

2
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by HasNor
0

Check your code for errors, or invalid connection information. Without more information from you, nobody can say anything sensible about it.

0

This file work in local host but do not work when run in server. When run in server view,update,insert user work OK but for this file is not working. Can you help me?

This is my code for file step1_req.php:

<?php
include 'template.php';
//$empNo=$_GET['empNo'];
include 'connection/db_connect.php';
$username = $_GET['username'];

$sql="SELECT * FROM user WHERE username='$username'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);

$sql2="SELECT * FROM category";
$result2=mysql_query($sql2);

?>
<style type="text/css">
<!--
.style3 {
	color: #6633CC;
	font-size: 18px;
	font-weight: bold;
}
-->
</style>


<form name="form1" method="post" action="db_step1.php?empNo=<?php echo $row['empNo']; ?>">
  <div align="center">
    <p>&nbsp;</p>
    <table width="367" height="228" border="1" cellpadding="1">
      <tr>
        <td><table width="367" height="41" border="0">
          <tr>
            <td><div align="center" class="style3">Step 1 : Select Category </div></td>
          </tr>
        </table>
          <table width="368" height="167" border="0">
            <tr>
              <td>Date </td>
              <td>:  
              <input name="date_req" type="text" id="date_req" value="<?php $curr_date = date("Ymd"); print $curr_date;?>" size="20" readonly="">
			  </td>
            </tr>
            <tr>
              <td>Department</td>
              <td>:             
              <input name="dept" type="text" id="dept" value=" <?php echo $row['dept']; ?>" size="20" readonly="">
              <input type="hidden" name="empNo" value=" <?php echo $row['empNo']; ?>"></td>
            </tr>
            <tr>
              <td><input type="hidden" name="misRefId" value=" <?php echo $row['dept'].'-'.$curr_date = date("Ymd")?>"></td>
              <td> 
              </td>
            </tr>
            <tr>
              <td>Category</td>
              <td>:
                <select name="category" id="category">
                  <option value="" selected="selected">-select-</option>
                  <?php
           			while($row2 = mysql_fetch_array($result2)) {
				  ?>
                  <option value="<?php echo $row2['cat_id']; ?>"><?php echo $row2['cat_name']; ?></option>
                  <?php } ?>
                </select>
                </td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td> <input name="Next" type="submit" id="Next" value="Next">
              <input type="hidden" name="username" value="<?php echo $username ?>"></td>
            </tr>
          </table></td>
      </tr>
    </table>
    <p>&nbsp;</p>
    </div>
</form>


<?php include 'copy.php'; ?>

file db_step1.php

<?php extract ($_POST);
include'connection/db_connect.php';
$empNo=$_GET['empNo'];
$username=$_GET['username'];
$category=$_POST['category'];
//$category=$_POST['type'];


$sql='INSERT INTO request set
request_by="'.$_POST['empNo'].'",
category="'.$_POST['category'].'",
dept="'.$_POST['dept'].'",
date_req="'.$_POST['date_req'].'",
misRefId="'.$_POST['misRefId'].'",
mis_appr="",
hodAppr="",
status=""';

$result=mysql_query($sql);

?>

<script type="text/javascript">
alert("Request already save!");
	window.location='step2_req.php?empNo=<?php echo $empNo ?>';</script>
0

Thank you "pritaeas"! i already try this code but it still doesn't work..it didn't show any error.. i dont know why it doesn't work when run in server..this is my database connection code :

<?php 
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');

$dbname1 = 'relogs';
mysql_select_db($dbname1);
?>
0

Add error reporting to your mysql_connect, mysql_select_db, and mysql_query's, just like line 6 above. Instead of a text, use die(mysql_error())

0

I got it!! hurm..actually i didn't tick for "null" value in field. Because my 1st page actually insert into certain fields not all that's why i have to give "null" value for the others.

Thank you for pritaeas for giving me help.. :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.