Styles2304 Posted March 15, 2009 Share Posted March 15, 2009 Here's the code I ran to setup my DB table: BonusInfo CREATE TABLE `black_arku`.`BonusInfo` (`IndexNo` SMALLINT NOT NULL ,`Bonus` TEXT NOT NULL ,`History` TEXT NOT NULL ,INDEX ( `IndexNo` )); And then here is the insert statement I'm trying to execute but I'm getting a syntax error: INSERT INTO `black_arku` . `BonusInfo` VALUES (1, '0', '0'); Is there something I'm missing? Link to comment https://forums.phpfreaks.com/topic/149538-problem-with-syntax/ Share on other sites More sharing options...
Rodis Posted March 15, 2009 Share Posted March 15, 2009 try this. INSERT INTO Name_of_the_table (black_arku , BonusInfo) VALUES ('1','0'); i removed one 0 because i don't understand if 2 fields are given why u are trying to insert 3 sets of data. The 1 corresponds to the field black_arku and the 0 to Bonusinfo in this example. Link to comment https://forums.phpfreaks.com/topic/149538-problem-with-syntax/#findComment-785344 Share on other sites More sharing options...
Styles2304 Posted March 15, 2009 Author Share Posted March 15, 2009 . . . No. `black_arku` is the database reference `BonusInfo` is the table. If you notice in the create, there are 3 fields: IndexNo, Bonus, and History. Anyone else have any ideas? Link to comment https://forums.phpfreaks.com/topic/149538-problem-with-syntax/#findComment-785372 Share on other sites More sharing options...
Rodis Posted March 15, 2009 Share Posted March 15, 2009 OK INSERT INTO Bonusinfo (IndexNo, Bonus, History) VALUES ('1','0','0'); This is the way your query should look. INSERT INTO Tablename (Fieldname, Fieldname, Fieldname) VALUES ('value','Value','Value'); Connection to the database should be made earlier. Link to comment https://forums.phpfreaks.com/topic/149538-problem-with-syntax/#findComment-785410 Share on other sites More sharing options...
Mchl Posted March 15, 2009 Share Posted March 15, 2009 What is the error you get? Link to comment https://forums.phpfreaks.com/topic/149538-problem-with-syntax/#findComment-785426 Share on other sites More sharing options...
corbin Posted March 15, 2009 Share Posted March 15, 2009 OK INSERT INTO Bonusinfo (IndexNo, Bonus, History) VALUES ('1','0','0'); This is the way your query should look. INSERT INTO Tablename (Fieldname, Fieldname, Fieldname) VALUES ('value','Value','Value'); Connection to the database should be made earlier. It is perfectly valid, acceptable and even semi-common to not select a database. The full name of a table can be used in a statement. INSERT INTO database.table..... Link to comment https://forums.phpfreaks.com/topic/149538-problem-with-syntax/#findComment-785458 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.