簡體   English   中英

特定查詢不在Godaddy主機上的php中運行

[英]particular query not running in php on Godaddy hosting

我試圖在我的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上檢查過, 這里只需要Localhost作為主機名即可。 我知道我粘貼了很長的一段代碼,但是不知道問題出在哪里。

您的代碼結尾處有一個錯字。

if ($r = mysqli_query($con, $select)) {
    echo 'data inserted successfully !';
    // do something ?
} // this one is missing 
else {
    echo '<script language="javascript">';
    echo 'alert("Information Not Inserted!!!");';
    //echo 'window.location.href="bill_generation.php";';
    echo '</script>';

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM