这个查询Mysql有什么问题。

时间:2015-09-26 07:35:36

标签: php mysql insert

  

#1064 - 您的SQL语法出错;检查手册   对应于您的MySQL服务器版本,以便使用正确的语法   靠近'其中id =' 29''在第4行

insert into supplier_details 
set supplier_tempid='scacsscacsa', name='naman gupta  gupta', type='dvsvds',sex='male', 
pno='scaasc', postno='12345', mobile='sacevw', email='ewvdv', language='ewvdvwe', service='fwvdv', 
country='sdvdvsvds', registered='Yes', address1='2979 sec-32 A chandigarh road', region='ewv qecsdv', 
community='cdsdcdsv', about='hello', comment='vdsdsvewv' where id='29'

5 个答案:

答案 0 :(得分:2)

INSERT查询不适用于where条件。你应该使用UPDATE查询。

update supplier_details set supplier_tempid='scacsscacsa', name='naman gupta  gupta', type='dvsvds',sex='male', pno='scaasc', postno='12345', mobile='sacevw', email='ewvdv', language='ewvdvwe', service='fwvdv', country='sdvdvsvds', registered='Yes', address1='2979 sec-32 A chandigarh road', region='ewv qecsdv', community='cdsdcdsv', about='hello', comment='vdsdsvewv' where id='29'

答案 1 :(得分:0)

这不是你INSERT的方式。它更像是一个UPDATE查询。

  

注意:您在查询中遇到一些错误,例如
  language='ewvdvwe, address1='2979 sec-32 A chandigarh road',和   其中id='29.所有人',其中一人sec-32 A chandigarh road',失效-

修复:

UPDATE  supplier_details 
        SET supplier_tempid='scacsscacsa', 
        name='naman gupta  gupta', 
        type='dvsvds',sex='male', 
        pno='scaasc', 
        postno='12345', 
        mobile='sacevw', 
        email='ewvdv', 
        language='ewvdvwe', 
        service='fwvdv', 
        country='sdvdvsvds', 
        registered='Yes', 
        address1='2979', 
        sec = '32 A chandigarh road', 
        region='ewv qecsdv', 
        community='cdsdcdsv', 
        about='hello', 
        comment='vdsdsvewv' 
        WHERE id='29';

答案 2 :(得分:0)

您正在混合插入和更新语法。它应该是

insert into supplier_details values('scacsscacsa', 'naman gupta  gupta', 'dvsvds','male', 'scaasc', '12345', 'sacevw', 'ewvdv', 'ewvdvwe', 'fwvdv', 'sdvdvsvds', 'Yes', '2979 sec-32 A chandigarh road', 'ewv qecsdv', 'cdsdcdsv', 'hello', 'vdsdsvewv')

update supplier_details set supplier_tempid='scacsscacsa', name='naman gupta  gupta', type='dvsvds',sex='male', pno='scaasc', postno='12345', mobile='sacevw', email='ewvdv', language='ewvdvwe', service='fwvdv', country='sdvdvsvds', registered='Yes', address1='2979 sec-32 A chandigarh road', region='ewv qecsdv', community='cdsdcdsv', about='hello', comment='vdsdsvewv' where id='29'

答案 3 :(得分:0)

如果你想插入那么rite格式是。

<?php

$dbc = mysqli_connect("localhost","username","password","database name");

$string = "INSERT INTO table_name(id, firstname, lastname) VALUES($_POST[id],$_POST[firstname],$_POST[lastname])";

$query = mysqli_query($dbc, $string);

?>

$ _ POST ['something']应该等于表单字段

中的name ='something'

答案 4 :(得分:0)

我认为这是你正在尝试做的事情:

UPDATE supplier_details SET supplier_tempid='scacsscacsa', name='naman gupta  gupta', type='dvsvds',sex='male', pno='scaasc', postno='12345', mobile='sacevw', email='ewvdv', language='ewvdvwe', service='fwvdv', country='sdvdvsvds', registered='Yes', address1='2979 sec-32 A chandigarh road', region='ewv qecsdv', community='cdsdcdsv', about='hello', comment='vdsdsvewv' WHERE id='29';

要更改已存在的ROW,您需要使用UPDATE语句。