bulrush Posted May 20, 2010 Share Posted May 20, 2010 I'm just not seeing an error in this SQL statement. Can anyone help me please? UPDATE group SET groupname='aaTest 2 group edited', SET basemodel='abh', SET classcode='', SET sin='', SET openmkt=0, SET updateuser='foo', SET updatedate=NOW() WHERE gid=28; But php returns an error when I use this code: if (!$result=mysqli_query($dbc,$query)) Quote Link to comment https://forums.phpfreaks.com/topic/202393-error-in-update/ Share on other sites More sharing options...
PFMaBiSmAd Posted May 20, 2010 Share Posted May 20, 2010 GROUP is a reserved mysql keyword and an unfortunate choice for a table name. Quote Link to comment https://forums.phpfreaks.com/topic/202393-error-in-update/#findComment-1061172 Share on other sites More sharing options...
bulrush Posted May 20, 2010 Author Share Posted May 20, 2010 Sorry. I modified some of the things. Here is the real SQL statement. UPDATE hgroup SET groupname='aaTest 2 group edited', SET basemodel='abh', SET classcode='', SET sin='', SET openmkt=0, SET updateuser='chuckr', SET updatedate=NOW() WHERE grid=28; I ran it through the phpMyAdmin sql processor, and it gave me an error, but everything looked ok. Here is the phpMyadmin sql error: SQL query: UPDATE hgroup SET groupname = 'aaTest 2 group edited', SET basemodel = 'abh', SET classcode = '', SET sin = '', SET openmkt =0, SET updateuser = 'chuckr', SET updatedate = NOW( ) WHERE grid =28 MySQL said: Documentation #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 'SET basemodel='abh', SET classcode='', SET sin='', SET openmkt=0, SET updateuser' at line 1 Oddly enough, all these fields work fine in an INSERT and SELECT statement. So it shouldn't be a problem with the field names, right? Quote Link to comment https://forums.phpfreaks.com/topic/202393-error-in-update/#findComment-1061174 Share on other sites More sharing options...
bulrush Posted May 20, 2010 Author Share Posted May 20, 2010 Here is my table layout. CREATE TABLE `hgroup` ( `grid` bigint(20) NOT NULL auto_increment, `createuser` varchar(15) NOT NULL default '', `createdate` datetime NOT NULL default '0000-00-00 00:00:00', `updateuser` varchar(15) default NULL, `updatedate` datetime default NULL, `groupname` varchar(80) NOT NULL default '', `image1` varchar(30) default NULL, `classcode` char(3) default NULL, `sin` varchar(30) default NULL, `openmkt` tinyint(1) NOT NULL default '0', `col1name` varchar(50) default NULL, `basemodel` varchar(50) default NULL, PRIMARY KEY (`grid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=33 ; When I reduce my query down to this: UPDATE hgroup SET groupname='aaTest 1 edited again', SET basemodel='AZA' WHERE grid=30; I start getting errors. That means, the field 'basemodel' is giving me errors somehow. Quote Link to comment https://forums.phpfreaks.com/topic/202393-error-in-update/#findComment-1061209 Share on other sites More sharing options...
bulrush Posted May 20, 2010 Author Share Posted May 20, 2010 I see the problem now, I should only use SET once. not multiple times. Quote Link to comment https://forums.phpfreaks.com/topic/202393-error-in-update/#findComment-1061237 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.