如何使用PHP更新mysql数据库? [英] How to update mysql database using PHP?

查看:130
本文介绍了如何使用PHP更新mysql数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个html来自和一个带有表调用客户的数据库,当我尝试使用表primark键更新数据库时,它给我下面的错误。



i have a html from and a database with a table call customer, when im trying to update the database using the table primark key it gives me below error.

Quote:

Error您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便在'='Nic'附近使用正确的语法,fullname ='F_Name',address ='Address',contact ='Contact',color ='Col'在第1行

ErrorYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= 'Nic',fullname = 'F_Name',address = 'Address',contact = 'Contact',color = 'Col' at line 1





如何解决这个问题?



我的尝试:





how to fix this?

What I have tried:

$connnect= mysqli_connect ("localhost","root","1234","latgsjason");
    if (mysqli_connect_error()){
    echo"Failed to Connect";
    }
        $VRegno= $_POST['V_Regno'];
        $Nic=$_POST['Nic'];
        $FullName=$_POST['F_Name'];
        $Address=$_POST['Address'];
        $Contact=$_POST['Contact'];
        $Color=$_POST['Color'];
				
        $sql = mysqli_query("Update customer SET nic='".$Nic."',fullname ='".$FullName."',address='".$Address."',contact='".$Contact."',color='".$Color."' where veh_regno='".$VRegno."'");
        if(!mysqli_query($connnect,$sql))
        {
            die("Error".mysqli_error($connnect));
        }
        echo"Update Successfully ";
        if(!isset($conn)){
        mysqli_close($conn);
        }



    }

推荐答案

connnect = mysqli_connect( 本地主机, 根, 1234, latgsjason);
if(mysqli_connect_error()){
echo连接失败;
}
connnect= mysqli_connect ("localhost","root","1234","latgsjason"); if (mysqli_connect_error()){ echo"Failed to Connect"; }


VRegno =


_POST ['V_Regno'];
_POST['V_Regno'];


这篇关于如何使用PHP更新mysql数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆