2017-06-19 109 views
-2

當我在我的管理面板中更新任何內容並點擊更新按鈕時,沒有任何反應 - 即它既沒有更新它,也沒有進入我們點擊編輯的頁面。我正在使用免費託管。相同的代碼在本地主機上工作,但它不適用於免費託管。誰能幫我?PHP/MySql更新查詢不起作用

$sqlN="UPDATE selectplan SET plan_name='$planname',Plandetails='$Plandetails', Plantime='$Plantime', Plandate='$Plandate', plancost='$plancost', img='$image' WHERE id='$id__' ;"; 
$resultN=mysqli_query($conn,$sqlN); 

下面是完整的代碼

<?php 
require "conn.php"; 

session_start(); 

if(!isset($_SESSION['id'])) 
{ 
    header('Location:index.php'); 
} 
else 
{ 
    $id__=$_GET['id']; 

    $sql="SELECT * from selectplan where id='$id__' ;"; 

    $result=mysqli_query($conn,$sql); 

    if((mysqli_num_rows($result))>0) 
    { 
     $row=mysqli_fetch_row($result); 
     $id_P=$row[0]; //id 
     $planname=$row[1];//name 
     $Plandetails=$row[2]; 
     $Plantime=$row[3]; 
     $Plandate=$row[4]; 
     $plancost=$row[5]; 
     $img__=$row[6]; 
    } 
} 
if (isset($_POST['submit'])) 
{ 
    $planname=$_POST["planname"];//name 
    $Plandetails=$_POST["Plandetails"]; 
    $Plantime=$_POST["Plantime"]; 
    $Plandate=$_POST["Plandate"]; 
    $plancost=$_POST["plancost"]; 
    if($planname==""||$Plandetails==""||$Plantime==""||$Plandate==""||$plancost=="") 
    { 
     echo "Please fill in all the fields"; 
    } 
    else 
    { 
     $target="images/".basename($_FILES['image']['name']); 

     //get all the submitted data from the form 
     $image=$_FILES['image']['name']; 

     //now move upload image to folder 
     if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) 
     { 
      echo "image upload"; 
     } 
     $sqlN="UPDATE selectplan SET plan_name='$planname',Plandetails='$Plandetails', Plantime='$Plantime', Plandate='$Plandate', plancost='$plancost', img='$image' WHERE id='$id__' ;"; 
     $resultN=mysqli_query($conn,$sqlN); 
     if ($resultN) { 
      header('Location:profile.php'); 
     } 
    } 
} 

?> 

<!DOCTYPE html> 
<html> 
<head> 
    <title>Edit Plan</title> 
</head> 
<body class="t"> 
<p><a href="userlist.php">Back to Profile</a> 
|| 
<a href="logout.php">Logout Now</a></p> 
<br> <br><br> 
    <form action="profile.php" method="POST" enctype="multipart/form-data" > 
     Plan Name:<br><textarea name="planname" id="" value="" cols="80" ><?php echo $planname; ?></textarea><br> 
     Plan Details:<br><textarea name="Plandetails" id="" value="" cols="80" rows="6"><?php echo $Plandetails; ?></textarea><br> 
     Plan Time:<br><input type="time" name="Plantime" id="" value="<?php echo $Plantime; ?>" /><br> 
     Plan Date:<br><input type="date" name="Plandate" id="" value="<?php echo $Plandate; ?>" /><br><br> 
     Plan Cost:<br><input type="numbers" name="plancost" id="" value="<?php echo $plancost; ?>" /><br><br> 
     Image:<br><?php echo "<img src='images/$img__'"; ?> alt="Tourism" height="150" width="300" > <br><input type="hidden" name="size" value="1000000"><input type="file" name="image" /><br></br> <input type="submit" name="submit" value="Update now "> 
    </form> 
</body> 
</html> 
+0

你試過打開PHP和MySQL錯誤檢查? –

+0

沒有一個單一的錯誤信息?您的表單是否被提交? –

+0

將以下兩行添加到腳本的開頭:'''error_reporting(E_ALL);''''''ini_set('display_errors','1');''' –

回答

0

我認爲你的問題是在conn.php 您的身份驗證值是不正確 在conn.php朝鮮年輕人聯合陣線應該改變目前本地主機和變化值用戶和通過