ag3nt42 Posted August 8, 2008 Share Posted August 8, 2008 can anyone tell me what is wrong with this query <?php $Inject[$y]="INSERT INTO [ClientsEmails] WHERE CompanyName='".$Company[$y]."' (username, password) VALUES ('".$username[$y]."','".$password[$y]."')"; ?> keep getting error saying syntax error near WHERE on line /\(that line) Quote Link to comment https://forums.phpfreaks.com/topic/118836-solved-invalid-syntax-with-query/ Share on other sites More sharing options...
wildteen88 Posted August 8, 2008 Share Posted August 8, 2008 IGNORE ME Quote Link to comment https://forums.phpfreaks.com/topic/118836-solved-invalid-syntax-with-query/#findComment-611909 Share on other sites More sharing options...
DarkWater Posted August 8, 2008 Share Posted August 8, 2008 You can't have a WHERE with an INSERT. And why the [ ] around the table name? Quote Link to comment https://forums.phpfreaks.com/topic/118836-solved-invalid-syntax-with-query/#findComment-611910 Share on other sites More sharing options...
ag3nt42 Posted August 8, 2008 Author Share Posted August 8, 2008 thats how it is in the DB and my DB wants me to use it.. also your sposed to be able to use a WHERE in insert statements \/ http://www.sql-tutorial.com/sql-where-sql-tutorial/ The WHERE keyword can be used to insert, update and delete data from table(s Quote Link to comment https://forums.phpfreaks.com/topic/118836-solved-invalid-syntax-with-query/#findComment-611911 Share on other sites More sharing options...
DarkWater Posted August 8, 2008 Share Posted August 8, 2008 No you're not. Are you trying to do an UPDATE instead...? INSERT WHERE makes no sense. Quote Link to comment https://forums.phpfreaks.com/topic/118836-solved-invalid-syntax-with-query/#findComment-611914 Share on other sites More sharing options...
ag3nt42 Posted August 8, 2008 Author Share Posted August 8, 2008 i spose i could use update.. but i'm not updating anything Quote Link to comment https://forums.phpfreaks.com/topic/118836-solved-invalid-syntax-with-query/#findComment-611916 Share on other sites More sharing options...
ag3nt42 Posted August 8, 2008 Author Share Posted August 8, 2008 dark.. I like the fact that you try to be helpful.. but I can't stand how arrogant you are about it.. really irritating. Quote Link to comment https://forums.phpfreaks.com/topic/118836-solved-invalid-syntax-with-query/#findComment-611918 Share on other sites More sharing options...
DarkWater Posted August 8, 2008 Share Posted August 8, 2008 Then what are you doing...? And I'm not being arrogant, believe me. o-O How am I being arrogant by saying that INSERT WHERE makes no sense? It doesn't. You're inserting a new row. There's nothing to WHERE about. Quote Link to comment https://forums.phpfreaks.com/topic/118836-solved-invalid-syntax-with-query/#findComment-611921 Share on other sites More sharing options...
ag3nt42 Posted August 8, 2008 Author Share Posted August 8, 2008 its not always what you say man its how you say it and if you want to get "makes sense" on it.. then yes it DOES make sense cuz i'm not updating any information.. I'm INSERTING brand new information. Quote Link to comment https://forums.phpfreaks.com/topic/118836-solved-invalid-syntax-with-query/#findComment-611924 Share on other sites More sharing options...
DarkWater Posted August 8, 2008 Share Posted August 8, 2008 Yeah, but you can't tell how I'm saying something on a forum. Believe me, I wasn't being arrogant. Now, what exactly are you trying to accomplish with this code? Quote Link to comment https://forums.phpfreaks.com/topic/118836-solved-invalid-syntax-with-query/#findComment-611927 Share on other sites More sharing options...
ag3nt42 Posted August 8, 2008 Author Share Posted August 8, 2008 sure you can. Quote Link to comment https://forums.phpfreaks.com/topic/118836-solved-invalid-syntax-with-query/#findComment-611928 Share on other sites More sharing options...
DarkWater Posted August 8, 2008 Share Posted August 8, 2008 Don't take every tutorial as pure truth. There can be mistakes. The MySQL manual for INSERT highlights the 3 syntax options as: INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [iGNORE] [iNTO] tbl_name [(col_name,...)] {VALUES | VALUE} ({expr | DEFAULT},...),(...),... [ ON DUPLICATE KEY UPDATE col_name=expr [, col_name=expr] ... ] Or: INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [iGNORE] [iNTO] tbl_name SET col_name={expr | DEFAULT}, ... [ ON DUPLICATE KEY UPDATE col_name=expr [, col_name=expr] ... ] Or: INSERT [LOW_PRIORITY | HIGH_PRIORITY] [iGNORE] [iNTO] tbl_name [(col_name,...)] SELECT ... [ ON DUPLICATE KEY UPDATE col_name=expr [, col_name=expr] ... ] No WHERE. =P It logically doesn't make much sense.... Quote Link to comment https://forums.phpfreaks.com/topic/118836-solved-invalid-syntax-with-query/#findComment-611940 Share on other sites More sharing options...
ag3nt42 Posted August 9, 2008 Author Share Posted August 9, 2008 thats just what I thought you'd say.. :-\ Quote Link to comment https://forums.phpfreaks.com/topic/118836-solved-invalid-syntax-with-query/#findComment-612138 Share on other sites More sharing options...
DarkWater Posted August 9, 2008 Share Posted August 9, 2008 thats just what I thought you'd say.. :-\ Uhh....okay...? Quote Link to comment https://forums.phpfreaks.com/topic/118836-solved-invalid-syntax-with-query/#findComment-612139 Share on other sites More sharing options...
Jabop Posted August 9, 2008 Share Posted August 9, 2008 Why was this bumped? Dark got the point across and you DO NOT insert WHERE. Quote Link to comment https://forums.phpfreaks.com/topic/118836-solved-invalid-syntax-with-query/#findComment-612140 Share on other sites More sharing options...
DarkWater Posted August 9, 2008 Share Posted August 9, 2008 Why was this bumped? Dark got the point across and you DO NOT insert WHERE. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/118836-solved-invalid-syntax-with-query/#findComment-612145 Share on other sites More sharing options...
ag3nt42 Posted August 10, 2008 Author Share Posted August 10, 2008 lol Quote Link to comment https://forums.phpfreaks.com/topic/118836-solved-invalid-syntax-with-query/#findComment-613075 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.