Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php到mysql更新查询未正常运行_Php_Mysql - Fatal编程技术网

php到mysql更新查询未正常运行

php到mysql更新查询未正常运行,php,mysql,Php,Mysql,更新 我现在可以通过在一页而不是2页上进行编码来更新它的实际值,但它仍然不会使用表单进行更新,我已经使它现在只能在固定电话上工作,直到我可以从表单中获得它 下面是没有html主体的新代码,它有一些指向php头的链接 $search = $_POST['search']; $search2 = $_POST['search2']; $results = mysqli_query($connection, "SELECT RecordReference, Dateofrecordcrea

更新

我现在可以通过在一页而不是2页上进行编码来更新它的实际值,但它仍然不会使用表单进行更新,我已经使它现在只能在固定电话上工作,直到我可以从表单中获得它

下面是没有html主体的新代码,它有一些指向php头的链接

    $search = $_POST['search']; 
$search2 = $_POST['search2'];

$results = mysqli_query($connection, "SELECT RecordReference, Dateofrecordcreation, Status, AgentName, ReturnFiledOn, InfoOnline, Surname, Forename, DateofBirth, UTR, NINO, Address, Postcode, AddressAffectiveFrom, Mobile, Landline, Email, Balance FROM `selfemployed` WHERE Surname LIKE '$search' AND Forename LIKE '$search2'"); 



while($row = mysqli_fetch_array($results))
{
$RecordReference = $row['RecordReference'];
$Dateofrecordcreation = $row['Dateofrecordcreation'];
$Status = $row['Status'];
$AgentName = $row['AgentName'];
$ReturnFiledOn = $row['ReturnFiledOn'];
$InfoOnline = $row['InfoOnline'];
$Surname = $row['Surname'];
$Forename = $row['Forename'];
$DateofBirth = $row['DateofBirth'];
$UTR = $row['UTR'];
$NINO = $row['NINO'];
$Address = $row['Address'];
$Postcode = $row['Postcode'];
$AddressAffectiveFrom = $row['AddressAffectiveFrom'];
$Mobile = $row['Mobile'];
$Landline = $row['Landline'];
$Email = $row['Email'];
$Balance = $row['Balance'];
}

if(isset($_POST['Update']))

$RecRef = $_POST['RecordReference'];
$Datereccr = $_POST['Dateofrecordcreation'];
$Sta = $POST['Status'];
$AgName = $_POST['AgentName'];
$Srnm = $_POST['Surname'];
$Frnm = $_POST['Forename'];
$DoB = $_POST['DateofBirth'];
$NatIn = $_POST['NINO'];
$Add = $_POST['Address'];
$Pstc = $_POST['Postcode'];
$AddAffFrm = $_POST['AddressAffectiveFrom'];
$UTaxR = $_POST['UTR'];
$Mob = $_POST['Mobile'];
$llffs = $_POST['Landline'];
$Eml = $_POST['Email'];
$RetFiled = $_POST['ReturnFiledOn'];
$Bal = $_POST['Balance'];
$Online = $_POST['InfoOnline'];
$id = $_POST['id'];

// Information to update
    $sql_query = "UPDATE `selfemployed` SET `Landline` = '$llffs' WHERE RecordReference = '$RecordReference'";
// Update Qquery
    mysqli_query($connection, $sql_query);

// Close our connection to the database
mysqli_close($connection);
?>
<!DOCTYPE html>
<html>
<style type="text/css">
<!--
$search=$\u POST['search'];
$search2=$_POST['search2'];
$results=mysqli_query($connection),“选择记录引用、记录创建日期、状态、代理名、返回文件名、在线信息、姓氏、姓名、出生日期、UTR、NINO、地址、邮政编码、地址影响、手机、固定电话、电子邮件、来自‘自营职业者’的余额,其中姓氏类似于‘搜索’、姓氏类似于‘搜索2’”);
while($row=mysqli\u fetch\u数组($results))
{
$RecordReference=$row['RecordReference'];
$Dateofrecordcreation=$row['Dateofrecordcreation'];
$Status=$row['Status'];
$AgentName=$row['AgentName'];
$ReturnFiledOn=$row['ReturnFiledOn'];
$InfoOnline=$row['InfoOnline'];
$LANSAME=$row['LANSAME'];
$Forename=$row['Forename'];
$DateofBirth=$row['DateofBirth'];
$UTR=$row['UTR'];
$NINO=$row['NINO'];
$Address=$row['Address'];
$Postcode=$row['Postcode'];
$AddressAffectiveFrom=$row['AddressAffectiveFrom'];
$Mobile=$row['Mobile'];
$Landline=$row['Landline'];
$Email=$row['Email'];
$Balance=$row['Balance'];
}
如果(isset($_POST['Update']))
$RecRef=$_POST['RecordReference'];
$Datereccr=$_POST['Dateofrecordcreation'];
$Sta=$POST[‘状态’];
$AgName=$\u POST['AgentName'];
$Srnm=$_POST[‘姓氏’];
$Frnm=$_POST['Forename'];
$DoB=$_POST['DateofBirth'];
$NatIn=$_POST['NINO'];
$Add=$_POST['Address'];
$Pstc=$_POST['Postcode'];
$addaffrm=$_POST['AddressAffectiveFrom'];
$UTaxR=$_POST['UTR'];
$Mob=$_POST['Mobile'];
$llffs=$_POST['Landline'];
$Eml=$_POST['Email'];
$RetFiled=$_POST['ReturnFiledOn'];
$Bal=$_POST['Balance'];
$Online=$_POST['InfoOnline'];
$id=$_POST['id'];
//需要更新的信息
$sql_query=“UPDATE`selfemployeed`SET`Landline`='$llffs',其中RecordReference='$RecordReference';
//更新Qquery
mysqli_查询($connection,$sql_查询);
//关闭与数据库的连接
mysqli_close($connection);
?>
参考资料:
>
公司状况:
活跃的
关闭
休眠的
凤凰
不再是顾客
代理名称::
>
这些信息在线吗
对
不
不适用
详细信息

姓: > 出生日期:: > 国民保险号 rows=“3”> 邮政编码:: > 手机:: > 平衡

未清余额:: 记录创建日期 地位 代理名称 于提交的报税表 姓 名字 出生日期 UTR 尼诺 地址 邮政编码 地址情感 可移动的 固定电话 电子邮件 平衡
这是更新代码

<?php
$RecordReference = $_POST['RecordReference'];
$date = date('d/m/Y h:i:s', time());
$Status = $_POST['Status'];
$AgentName = $_POST['AgentName'];
$ReturnFiledOn = $_POST['DateReturnFiled'];
$InfoOnline = $_POST['Online'];
$Surname = $_POST['Surname'];
$Forename =$_POST['Forename'];
$DateofBirth = $_POST['DateofBirth'];
$UTR = $_POST['UTR'];
$NINO = $_POST['NINO'];
$Address = $_POST['Address'];
$Postcode = $_POST['Postcode'];
$AddressAffectiveFrom = $_POST['AddressAffectiveFrom'];
$Mobile = $_POST['Mobile'];
$Landline = $_POST['Landline'];
$Email = $_POST['Email'];
$Balance = $_POST['Balance'];
// Connect to the database

require_once "config.php";

// update data in mysqli database 
$sql = ("UPDATE selfemployed SET RecordReference = '$RecordReference', Dateofrecordcreation = '$date', Status = '$Status', AgentName = '$AgentName', ReturnFiledOn = '$ReturnFiledOn', InfoOnline = '$InfoOnline', Surname = '$Surname', Forename = '$Forename', DateofBirth = '$DateofBirth', UTR = '$UTR', NINO = '$NINO', Address = '$Address', Postcode = '$Postcode', AddressAffectiveFrom = '$AddressAffectiveFrom', Mobile = '$Mobile', Landline = '$Landline', Email = '$Email', Balance = '$Balance' WHERE RecordReference = '$RecordReference'");

// Close our connection to the database
mysqli_close($connection);
?>


<script type="text/javascript">
window.history.go(-2);
</script>


请尝试使用准备好的语句(mysqli stmts或pdo)来避免SQL注入。

如果您从未运行过更新查询,请像下面这样运行更新查询

$sql = "UPDATE selfemployed SET RecordReference = '$RecordReference', Dateofrecordcreation = '$date', Status = '$Status', AgentName = '$AgentName', ReturnFiledOn = '$ReturnFiledOn', InfoOnline = '$InfoOnline', Surname = '$Surname', Forename = '$Forename', DateofBirth = '$DateofBirth', UTR = '$UTR', NINO = '$NINO', Address = '$Address', Postcode = '$Postcode', AddressAffectiveFrom = '$AddressAffectiveFrom', Mobile = '$Mobile', Landline = '$Landline', Email = '$Email', Balance = '$Balance' WHERE RecordReference = '$RecordReference'";
// Update Qquery
mysqli_query($connection, $sql);

// Close our connection to the database
mysqli_close($connection);

事实证明,当我将所有内容都放在一个页面上时,我所需要做的就是将更新按钮ID和名称从一个更新更改为另一个更新,然后它就完美地工作了。

嘿!请尽量只向我们显示相关代码,因此没有html和css。例如,您从未执行更新查询。请添加
$run=mysqli\u查询($connection,$sql)
,然后应该对您进行分类问题是什么?您有错误吗?以后再也不要在网上发布您的数据库登录详细信息。目前最重要的步骤是更改您的数据库登录凭据。你不仅在网上分享了它们,还有一些人指出了这一点。仅仅编辑当前帖子是不够的;这里的一些人仍然可以看到原来的帖子。@MasivuyeCokile如果你相信的话,也许你应该解释一下原因。对不起,我的错。首先忘记了一个参数。@BenHillier编辑
mysqli\u query()
之前的初始答案只有一个参数。我尝试了上面的代码,并将sql改为$sql,但没有效果。不,它运行了所有操作,但只是不更新数据。不,我很惊讶。你能告诉我你在显示错误时得到的确切错误吗?像这样尝试mysqli\u查询($connection,$sql)或die(mysqli_error($connection));没有错误,代码运行并返回到原始页面(后退2步)但更新不适用,例如-电话为空,因此我在电话框中输入一个号码,按submit,代码运行并将我重定向到仪表板,但当我使用搜索功能检查输入时,它会显示原始数据,没有任何更改,更改也不会显示在数据库上。我可以手动更新数据库,但我的客户无法继续登录以完成此操作,他们需要能够通过查询完成此操作。@Mukesh Jakhar I trie
// update data in mysqli database 
$sql = "UPDATE selfemployed SET RecordReference = '$RecordReference', Dateofrecordcreation = '$date', Status = '$Status', AgentName = '$AgentName', ReturnFiledOn = '$ReturnFiledOn', InfoOnline = '$InfoOnline', Surname = '$Surname', Forename = '$Forename', DateofBirth = '$DateofBirth', UTR = '$UTR', NINO = '$NINO', Address = '$Address', Postcode = '$Postcode', AddressAffectiveFrom = '$AddressAffectiveFrom', Mobile = '$Mobile', Landline = '$Landline', Email = '$Email', Balance = '$Balance' WHERE RecordReference = '$RecordReference'";
//Send query
mysqli_query($connection, $sql);

// Close our connection to the database
mysqli_close($connection);
$sql = "UPDATE selfemployed SET RecordReference = '$RecordReference', Dateofrecordcreation = '$date', Status = '$Status', AgentName = '$AgentName', ReturnFiledOn = '$ReturnFiledOn', InfoOnline = '$InfoOnline', Surname = '$Surname', Forename = '$Forename', DateofBirth = '$DateofBirth', UTR = '$UTR', NINO = '$NINO', Address = '$Address', Postcode = '$Postcode', AddressAffectiveFrom = '$AddressAffectiveFrom', Mobile = '$Mobile', Landline = '$Landline', Email = '$Email', Balance = '$Balance' WHERE RecordReference = '$RecordReference'";
// Update Qquery
mysqli_query($connection, $sql);

// Close our connection to the database
mysqli_close($connection);