这个查询 Mysql. 有什么问题?
What's wrong in this query Mysql.?
#1064 - You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'where id='29'' at line 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'
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'
你不是这样的INSERT
。它更像是一个 UPDATE
查询。
Notice: you have some errors in the query like
language='ewvdvwe,
address1='2979
sec-32 A chandigarh road',
and
where id='29.
All of them missing '
and one of them sec-32 A chandigarh road',
with invalid -
修复:
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';
您正在混合插入和更新语法。应该是
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'
如果你想插入那么仪式格式是。
<?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'
我想这就是你想要做的:
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';
要更改已存在的行,您需要使用 UPDATE 语句。
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where id='29'' at line 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'
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'
你不是这样的INSERT
。它更像是一个 UPDATE
查询。
Notice: you have some errors in the query like
language='ewvdvwe,
address1='2979
sec-32 A chandigarh road',
and whereid='29.
All of them missing'
and one of themsec-32 A chandigarh road',
with invalid-
修复:
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';
您正在混合插入和更新语法。应该是
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'
如果你想插入那么仪式格式是。
<?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'
我想这就是你想要做的:
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';
要更改已存在的行,您需要使用 UPDATE 语句。