MySQL PHP表更新/发布不工作

MySQL PHP表更新/发布不工作,php,mysql,post,get,edit,Php,Mysql,Post,Get,Edit,我一直在处理一个待办事项列表,该列表允许具有管理员权限的人员从表单中编辑/更新公司内所有员工的多个百分比。发送的数据可能在50-200个条目之间的任何位置,并且一次更新所有条目 我一直面临的问题是,表单和页面在我的XAMPP本地机器上运行得非常好,并在更新过程中运行,但是,一旦我将其上传到实时FTP,它就不会运行了。在live server上,当我单击submit按钮时,它会加载并刷新页面,但没有更新任何值,也不会重定向到正确的页面(事实上,它保持在同一页面上) 我的PHP有点生疏,解决方案可能

我一直在处理一个待办事项列表,该列表允许具有管理员权限的人员从表单中编辑/更新公司内所有员工的多个百分比。发送的数据可能在50-200个条目之间的任何位置,并且一次更新所有条目

我一直面临的问题是,表单和页面在我的XAMPP本地机器上运行得非常好,并在更新过程中运行,但是,一旦我将其上传到实时FTP,它就不会运行了。在live server上,当我单击submit按钮时,它会加载并刷新页面,但没有更新任何值,也不会重定向到正确的页面(事实上,它保持在同一页面上)

我的PHP有点生疏,解决方案可能很简单,但就我的一生而言,我似乎无法对它指手画脚

这是我的守则,任何对此的建设性批评都将不胜感激

<strong>Update Bulk To Do List</strong><br><br>

<?php 
$host="localhost"; // Host name 
$username=""; // Mysql username 
$password=""; // Mysql password 
$db_name=""; // Database name 
$tbl_name="kpi"; // Table name 

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$sql="SELECT * FROM $tbl_name ORDER BY country, person, type, lpad(jobnr, 100, 0)";
$result=mysql_query($sql);

// Count table rows 
$count=mysql_num_rows($result);
?>




<table width="100%" border="0" cellspacing="0" cellpadding="0" class='responsive'>
<form name="form1" method="post" action="">
<tr> 
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<col width=3%>
<col width=5%>
<col width=3%>
<col width=15%>
<col width=35%>
<col width=15%>
<col width=18%>

<tr style='color: #fff; border-top: #d2d8db solid 2px; border-bottom: #d2d8db solid 2px'>
<td id='blue' bgcolor='#39a8f9' align="left" ><strong>ID</strong></td>
<td id='blue' bgcolor='#39a8f9' align="center"><strong>Name</strong></td>
<td id='blue' bgcolor='#39a8f9' align="center"><strong>No.</strong></td>
<td id='blue' bgcolor='#39a8f9' align="center"><strong>Brief</strong></td>
<td id='blue' bgcolor='#39a8f9' align="center"><strong>Detail</strong></td>
<td id='blue' bgcolor='#39a8f9' align="center"><strong>Type</strong></td>
<td id='blue' bgcolor='#39a8f9' align="center"><strong>%</strong></td>
</tr>

<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td align="left" id='hovereff' style='border-bottom: #d2d8db solid 1px!important;'><?php $id[]=$rows['id']; ?><?php echo $rows['id']; ?></td>
<td align="center" bgcolor='#2c3e6c' id='hovereff' style='border-bottom: #d2d8db solid 1px!important;'><?php echo $rows['person']; ?><input type='hidden' id='person' name='person[]' value="<?php echo $rows['person']; ?>"></td>
<td align="center" bgcolor='#2c3e6c' id='hovereff' style='border-bottom: #d2d8db solid 1px!important;'><?php echo $rows['jobnr']; ?><input type='hidden' id='jobnr' name='jobnr[]' value="<?php echo $rows['jobnr']; ?>"></td>
<td align="left" bgcolor='#2c3e6c' id='hovereff' style='border-bottom: #d2d8db solid 1px!important;'><?php echo $rows['brief']; ?><input type='hidden' id='brief' name='brief[]' value="<?php echo $rows['brief']; ?>"></td>
<td align="left" bgcolor='#2c3e6c' id='hovereff' style='border-bottom: #d2d8db solid 1px!important;'><?php echo $rows['detail']; ?><input type='hidden' id='detail' name='detail[]' value="<?php echo $rows['detail']; ?>"></td>
<td align="center" bgcolor='#2c3e6c' id='hovereff' style='border-bottom: #d2d8db solid 1px!important;'><?php echo $rows['type']; ?><input type='hidden' id='type' name='type[]' value="<?php echo $rows['type']; ?>"></td>
<td align="center" bgcolor='#2c3e6c' id='hovereff' style='border-bottom: #d2d8db solid 1px!important;'>
<input name="overall_result[]" type="text" id="overall_result" value="<?php echo $rows['overall_result']; ?>">
<input type='hidden' id='expectation' name='expectation[]' value="<?php echo $rows['expectation']; ?>">
<input type='hidden' id='comments' name='comments[]' value="<?php echo $rows['comments']; ?>">
<input type='hidden' id='status' name='status[]' value="<?php echo $rows['status']; ?>">
<input type='hidden' id='country' name='country[]' value="<?php echo $rows['country']; ?>">
<input type='hidden' id='week' name='week[]' value="<?php date('d/m/Y', strtotime("Next Friday"))?>">


</td>
</tr>
<?php
}
?>
<tr>
<td colspan="7" align="right"><input type="submit" name="submit" class="upbutton" value="Update List"></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
<?php
// Check if button name "submit" is active, do this 
if(isset($_POST['submit'])){
$person=$_POST['person'];
$jobnr=$_POST['jobnr'];
$brief=$_POST['brief'];
$detail=$_POST['detail'];
$overall_result=$_POST['overall_result'];
$comments=$_POST['comments'];
$status=$_POST['status'];
$country=$_POST['country'];
$week=$_POST['week'];
$expectation=$_POST['expectation'];
$type=$_POST['type'];


for($i=0;$i<$count;$i++){
$sql1="UPDATE $tbl_name SET person='$person[$i]', jobnr='$jobnr[$i]', brief='$brief[$i]' , detail='$detail[$i]' , expectation='$expectation[$i]', overall_result='$overall_result[$i]' , comments='$comments[$i]', status='$status[$i]', country='$country[$i]' , type='$type[$i]' , week='$week[$i]' WHERE id='$id[$i]'";
$query4=mysql_query("UPDATE kpi_ytd SET person='$person[$i]', jobnr='$jobnr[$i]', brief='$brief[$i]' , detail='$detail[$i]' , expectation='$expectation[$i]', overall_result='$overall_result[$i]' , comments='$comments[$i]', status='$status[$i]', country='$country[$i]' , type='$type[$i]' , week='$week[$i]' WHERE id='$id[$i]'");
$query5=mysql_query("insert into kpi_records values('','$person[$i]','$jobnr[$i]','$week[$i]','$brief[$i]','$detail[$i]','$expectation[$i]','$overall_result[$i]','$comments[$i]', '$status[$i]', '$country[$i]', '$type[$i]')");
$result1=mysql_query($sql1);
}
}
if(isset($result1)){
echo("<h3>Please Wait,<br>Updating Branch Tasks...</h3><script>location.href = '/list.php';</script>");
}
?>
更新批量待办事项列表

ID 名称 否。 简介 细节 类型 %
若您可以确保在线服务器上的配置主机、用户和密码数据库是正确的

从我读到的内容来看,您必须尝试将您的代码“mysqli”更改为“mysqli”

例如:

mysql_connect("$host", "$username", "$password")or die("cannot connect"); 


我的答案将根据您的评论而改变,因为我不知道您的内容。

您很容易受到攻击,只是假设您的查询应该正常工作。错误的假设。永远不要假设成功。始终检查故障:
$result=mysql\u query($sql)或die(mysql\u error())如果有错误,您会看到哪些错误?如果没有,请尝试打开
error\u reporting
在上载到服务器时是否将用户名和密码更改为服务器的凭据?在实时FTP上主机、用户名和密码是否正确?@CodeGodie,我打开了错误报告并得到以下信息:“不推荐使用:mysql\u connect():mysql扩展已弃用,将来将被删除:在/home/../public_html/team/myfile.php中使用mysqli或PDO。我还检查了一遍又一遍我的用户名和密码到服务器,那里一切正常。
mysqli_connect("$host", "$username", "$password")or die("cannot connect");