特定查询不在Godaddy主机上的php中运行

时间:2018-09-25 10:46:27

标签: php mysql

我正在尝试在我的php页面上运行插入查询,但是该查询未执行,将我带到其他部分。 我已经在MySQL上检查查询了。另外,我在同一页面上有几个选择查询,这些查询工作正常。因此,我确定连接或访问数据库没有问题。这是我的代码:

<?php
 session_start();
 include './db_config.php';

 if ((!isset($_SESSION['first_name']) == true)) {
unset($_SESSION['first_name']);
} 
$logged = $_SESSION['first_name'];

 if ((!isset($_SESSION['id']) == true)) {
unset($_SESSION['id']);
} 
$id = $_SESSION['id']; 

if ((!isset($_SESSION['email']) == true)) {
unset($_SESSION['email']);
}
$email= $_SESSION['email'];  


$query1 = "select * from user_master where id='$id'";
$result1 = mysqli_query($con, $query1);
$num1 = mysqli_num_rows($result1);
if ($num1 > 0) {
  while ($data = $result1->fetch_assoc()) {
    $branch_name = $data['branch_name'];

 } 
}
if(isset($_POST['save'])){
$cust_id=$_POST['cust_id']; 
$meter_no=$_POST['meter_no'];
$lock_no=$_POST['lock_no'];
$customer_name=$_POST['customer_name'];
$customer_type=$_POST['customer_type'];
$customer_zone=$_POST['customer_zone'];
$status=$_POST['status'];
$phoneno=$_POST['phoneno'];
$city=$_POST['city'];
$address=$_POST['address'];
$houseno=$_POST['houseno'];
$ownership=$_POST['ownership'];
$landmark=$_POST['landmark'];
$opening_reading=$_POST['opening_reading'];
$opening_reading_date=$_POST['opening_reading_date'];
$branch_name=$_POST['branch_name'];
$created_on=$_POST['created_on'];
$created_by=$_POST['created_by'];
$email=$_POST['email']; 
$consumption=0;
$current_reading=$opening_reading;
$status1="True";
$total_bill=0;
$total_paid=0;
$total_dues=0;

$select="insert into meter(cust_id,meter_no,lock_no,customer_name,customer_type,customer_zone,status,phoneno,city,address,houseno,ownership,landmark,opening_reading,opening_reading_date,created_on,branch_name,created_by,email)
 VALUES('$cust_id','$meter_no','$lock_no','$customer_name','$customer_type','$customer_zone','$status','$phoneno','$city','$address','$houseno','$ownership','$landmark','$opening_reading','$opening_reading_date','$created_on','$branch_name','$created_by','$email')";
            if ($r = mysqli_query($con, $select)) {
            else {
                echo '<script language="javascript">';
                echo 'alert("Information Not Inserted!!!");';
                //echo 'window.location.href="bill_generation.php";';
                echo '</script>';

            }

}

我已经检查了Godaddy HERE,它只需要Localhost作为主机名。 我知道我粘贴了很长的代码,但是不知道问题出在哪里。

1 个答案:

答案 0 :(得分:1)

代码结尾处有错字。

       for (var counterOfLoop in data)
       { 
          var id = data[counterOfLoop]['_id']['$oid'];
          ....
              "<td class='col-sm-2'>"+
                                           '<select id="route_'+ id+'" name="route'+id+'" type="text" class="form-control validate-required" onchange="fetchAllStops(this.value,"'+id+'"")"> </select>'+
                                           "</td>"+

           }