1064:You have an error in your SQL syntax - mysql
1064:You have an error in your SQL syntax
Is this error sql injectiable because personally I'm afraid I dont know how to fix it and if it is injectable i need to fix it fast?
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 '%' or categoryMark like '%'%' or packageName like '%'%')' at line 1 [ SQL ] : select count(id) as count from microvirt_app_i18n where advertiser = 'google' and color0 and countrycode = 'US' and (name like '%'%' or categoryMark like '%'%' or packageName like '%'%')
错误位置
FILE: /var/www/html/home/ThinkPHP/Library/Think/Db/Driver.class.php LINE: 350
TRACE
#0 /var/www/html/home/ThinkPHP/Library/Think/Db/Driver.class.php(350): E('1064:You have a...')
#1 /var/www/html/home/ThinkPHP/Library/Think/Db/Driver.class.php(180): Think\Db\Driver->error()
#2 /var/www/html/home/ThinkPHP/Library/Think/Model.class.php(1382): Think\Db\Driver->query('select count(id...')
#3 /var/www/html/home/Application/Home/Controller/SearchController.class.php(31): Think\Model->query('select count(id...')
#4 [internal function]: Home\Controller\SearchController->index(''', 'en')
#5 /var/www/html/home/ThinkPHP/Library/Think/App.class.php(171): ReflectionMethod->invokeArgs(Object(Home\Controller\SearchController), Array)
#6 /var/www/html/home/ThinkPHP/Library/Think/App.class.php(110): Think\App::invokeAction(Object(Home\Controller\SearchController), 'index')
#7 /var/www/html/home/ThinkPHP/Library/Think/App.class.php(204): Think\App::exec()
#8 /var/www/html/home/ThinkPHP/Library/Think/Think.class.php(120): Think\App::run()
#9 /var/www/html/home/ThinkPHP/ThinkPHP.php(97): Think\Think::start()
#10 /var/www/html/home/index.php(33): require('/var/www/html/h...')
The error tells you where to look...
near '%' or categoryMark like '%'%' or packageName like '%'%')'
The strings '%'%' have a ' in the middle, which you haven't escaped.
Try '%''%' instead
(Where '' is treated as a literal character, rather than a string terminator).
As for whether it's injectable, any time you substitute strings in to queries, it's injectable.
Use parameterisation instead.
Parameterized queries in PHP with MySQL connection
Related
Command raised an exception: OperationalError: near "<": syntax error sqlite3 discord.py
cursor.execute(f"UPDATE blackasjackas SET pirmas_korta = {pirmas_korta} WHERE userid={ctx.author.id}") I'm having a problem with this line, it's giving me the operationalerror near "<" and I can't seem to figure out how to fix it pirmas_korta returns a string "<:2H:804013503354634280>"
I'm not a python specialist, but SQL-standart requires strings to be apostrophed, so since pirmas_korta is some kind of a string value, update statement should look like the following f"UPDATE blackasjackas SET pirmas_korta = '{pirmas_korta}' WHERE userid={ctx.author.id}"
C++ Converting protobuf in json
I'am trying to connect some data from protobuf to json. This are the relevants parts of my code: Message* m; std::string json; std::string binary_s; ...fill the message... m->serializeToString(&binary_s); MessageToJsonString(*m, &json); The istruction below works fine and produced the expected output. m->serializeToString(&binary_s); But when I try to convert it into json, this error always appear: Program received signal SIGSEGV, Segmentation fault. google::protobuf::DescriptorPool::FindFileByName (this=0x0, name="FLATBUFFER_DEFINITION.proto") at google/protobuf/descriptor.cc:1415 1415 MutexLockMaybe lock(mutex_); (gdb) backtrace #0 google::protobuf::DescriptorPool::FindFileByName (this=0x0, name="AutoPilot.proto") at google/protobuf/descriptor.cc:1415 #1 0x00007ffff7aba42d in google::protobuf::internal::AssignDescriptors (filename="AutoPilot.proto", schemas=0x4463a0 <protobuf_AutoPilot_2eproto::schemas>, default_instances_=0x446500 <protobuf_AutoPilot_2eproto::file_default_instances>, offsets=0x445c20 <protobuf_AutoPilot_2eproto::TableStruct::offsets>, factory=0x0, file_level_metadata=0x665020 <protobuf_AutoPilot_2eproto::file_level_metadata>, file_level_enum_descriptors=0x6651e0 <protobuf_AutoPilot_2eproto::file_level_enum_descriptors>, file_level_service_descriptors=0x0) at google/protobuf /generated_message_reflection.cc:2316 #2 0x000000000040730c in protobuf_AutoPilot_2eproto::protobuf_AssignDescriptors() () #3 0x00007ffff7a24bd5 in google::protobuf::internal::FunctionClosure0::Run (this=0x7fffffffda90) at ./google/protobuf/stubs/callback.h:129 #4 google::protobuf::GoogleOnceInitImpl ( once=0x665388 <protobuf_AutoPilot_2eproto::protobuf_AssignDescriptorsOnce()::once>, closure=0x7fffffffda90) at google/protobuf/stubs/once.cc:83 #5 0x0000000000433abb in google::protobuf::GoogleOnceInit(long*, void (*)()) () #6 0x0000000000407383 in protobuf_AutoPilot_2eproto::protobuf_AssignDescriptorsOnce() () #7 0x0000000000431503 in Message::GetMetadata() const () #8 0x00007ffff7b536cc in google::protobuf::Message::GetDescriptor (this=0x68e0b0) at ./google/protobuf/message.h:336 #9 google::protobuf::util::MessageToJsonString (message=warning: RTTI symbol not found for class 'Message' ..., output=0x7fffffffdd60, options=...) at google/protobuf/util/json_util.cc:217 It seems like it can't find the file "FLATBUFFER_DEFINITION.proto", but it is in the same directory of the executable.
google::protobuf::DescriptorPool::FindFileByName **(**this=0x0**,** name="FLATBUFFER_DEFINITION.proto") at google/protobuf/descriptor.cc:1415 1415 MutexLockMaybe lock(mutex_); Object pointer is null. I had call ShutdownProtobufLibrary(); and after ,continue using his functions.
Mediawiki dies with FileBackendException: 'Backend with name `shared-backend` already registered'
I am trying to setup Mediawiki. I have confirmed that i am able to load Special pages (any of them), but when it comes to the regular pages the site dies with the following: Exception encountered, of type "FileBackendException" [32b52f48] /Main_Page FileBackendException from line 125 of /......../mediawiki/includes/filebackend/FileBackendGroup.php: Backend with name `shared-backend` already registered. Backtrace: #0 /......../mediawiki/includes/filebackend/FileBackendGroup.php(109): FileBackendGroup->register(array) #1 /......../mediawiki/includes/filebackend/FileBackendGroup.php(47): FileBackendGroup->initFromGlobals() #2 /......../mediawiki/includes/filerepo/FileRepo.php(152): FileBackendGroup::singleton() #3 /......../mediawiki/includes/filerepo/LocalRepo.php(54): FileRepo->__construct(array) #4 /......../mediawiki/includes/filerepo/RepoGroup.php(418): LocalRepo->__construct(array) #5 /......../mediawiki/includes/filerepo/RepoGroup.php(403): RepoGroup->newRepo(array) #6 /......../mediawiki/includes/filerepo/RepoGroup.php(228): RepoGroup->initialiseRepos() #7 /......../mediawiki/includes/GlobalFunctions.php(4079): RepoGroup->checkRedirect(Title) #8 /......../mediawiki/includes/parser/Parser.php(2247): wfIsBadImage(string, Title) #9 /......../mediawiki/includes/parser/Parser.php(2013): Parser->replaceInternalLinks2(string) #10 /......../mediawiki/includes/parser/Parser.php(1262): Parser->replaceInternalLinks(string) #11 /......../mediawiki/includes/parser/Parser.php(439): Parser->internalParse(string) #12 /......../mediawiki/includes/content/WikitextContent.php(331): Parser->parse(string, Title, ParserOptions, boolean, boolean, integer) #13 /......../mediawiki/includes/content/AbstractContent.php(497): WikitextContent->fillParserOutput(Title, integer, ParserOptions, boolean, ParserOutput) #14 /......../mediawiki/includes/poolcounter/PoolWorkArticleView.php(140): AbstractContent->getParserOutput(Title, integer, ParserOptions) #15 /......../mediawiki/includes/poolcounter/PoolCounterWork.php(123): PoolWorkArticleView->doWork() #16 /......../mediawiki/includes/page/Article.php(676): PoolCounterWork->execute() #17 /......../mediawiki/includes/actions/ViewAction.php(44): Article->view() #18 /......../mediawiki/includes/MediaWiki.php(490): ViewAction->show() #19 /......../mediawiki/includes/MediaWiki.php(287): MediaWiki->performAction(Article, Title) #20 /......../mediawiki/includes/MediaWiki.php(714): MediaWiki->performRequest() #21 /......../mediawiki/includes/MediaWiki.php(508): MediaWiki->main() #22 /......../mediawiki/index.php(41): MediaWiki->run() #23 {main} Unfortunately there is no documentation that i can find anywhere that deals with this exception apart from this which isn't of much use. I have tried disabling all of the extensions, thinking that some of them may be at fault, generating some object that needs to remain as a singleton, but that didn't help. $wgFileBackends is only defined once in DefaultSettings.php. # grep -R 'wgFileBackends' . ./includes/DefaultSettings.php: * The name "local-fs" should correspond by name to an entry in $wgFileBackends. ./includes/DefaultSettings.php: * #see $wgFileBackends ./includes/DefaultSettings.php: * - backend A file backend name (see $wgFileBackends). ./includes/DefaultSettings.php:$wgFileBackends = array(); ./includes/filebackend/FileBackendGroup.php: global $wgLocalFileRepo, $wgForeignFileRepos, $wgFileBackends; ./includes/filebackend/FileBackendGroup.php: $this->register( $wgFileBackends ); ./includes/filebackend/README:$wgFileBackends. To access one of those defined backends, one would use ./includes/externalstore/ExternalStoreMwstore.php: * The file backends must be defined in $wgFileBackends and must be global ./tests/phpunit/includes/filebackend/FileBackendTest.php: global $wgFileBackends; ./tests/phpunit/includes/filebackend/FileBackendTest.php: foreach ( $wgFileBackends as $conf ) { ./tests/phpunit/includes/filerepo/StoreBatchTest.php: global $wgFileBackends; ./tests/phpunit/includes/filerepo/StoreBatchTest.php: foreach ( $wgFileBackends as $conf ) { ./tests/phpunit/includes/parser/NewParserTest.php: global $wgFileBackends; ./tests/phpunit/includes/parser/NewParserTest.php: foreach ( $wgFileBackends as $conf ) {
Thanks to Tgr's comments i was able to figure out the answer. The problem was the $wgForeignFileRepos array that was defined in the LocalSettings.php. It was left from the previous version of Mediawiki, where apparently same names were not the problem. It is essential that the names given to the cells is different and none can be titled 'shared'. This point is actually made on the $wgForeignFileRepos documentation page: $wgForeignFileRepos[] = array( 'class' => 'ForeignAPIRepo', 'name' => 'commonswiki', // Must be a distinct name 'apibase' => 'https://commons.wikimedia.org/w/api.php', 'hashLevels' => 2, ... );
How do I fix this SQL syntax error, I cannot find it
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 'INSERT INTO ******_sports_teams (******_team_id, ******_content_type_id, ******' at line 2 That is the error I get to this script; The stars cover the name of the company I work for that I cannot release, but they are all the same word that I know is spelled correctly. SELECT * FROM `******_sports_teams` WHERE 1 INSERT INTO ******_sports_teams (******_team_id, ******_content_type_id, ******_content_type_desc, ******_sport_name, ******_sport_confernece, ******_sport_division, ******_sport_city, ******_sport_team) VALUES (1,4,'Sports','NBA','Eastern','Atlantic','Boston','Celtics'), (2,4,'Sports','NBA','Eastern','Atlantic','Brooklyn','Nets'), (3,4,'Sports','NBA','Eastern','Atlantic','Newy York','Knicks'), (4,4,'Sports','NBA','Eastern','Atlantic','Philedelphia','76ers'), (5,4,'Sports','NBA','Eastern','Atlantic','Toronto','Raptors'), (6,4,'Sports','NBA','Eastern','Central','Chicago','Bulls'), (7,4,'Sports','NBA','Eastern','Central','Cleveland','Cavaliers'), (8,4,'Sports','NBA','Eastern','Central','Detriot','Pistons'), (9,4,'Sports','NBA','Eastern','Central','Indiana','Pacers'), (10,4,'Sports','NBA','Eastern','Central','Milwaukee','Bucks'), (11,4,'Sports','NBA','Eastern','Southeast','Atlanta','Hawks'), (12,4,'Sports','NBA','Eastern','Southeast','Charlotte','Hornets'), (13,4,'Sports','NBA','Eastern','Southeast','Miami','Heat'), (14,4,'Sports','NBA','Eastern','Southeast','Orlando','Magic'), (15,4,'Sports','NBA','Eastern','Southeast','Washington','Wizards'), (16,4,'Sports','NBA','Western','Southwest','Dallas','Mavericks'), (17,4,'Sports','NBA','Western','Southwest','Houston','Rockets'), (18,4,'Sports','NBA','Western','Southwest','Memphis','Grizzlies'), (19,4,'Sports','NBA','Western','Southwest','New Orleans','Pelicans'), (20,4,'Sports','NBA','Western','Southwest','San Antonio','Spurs'), (21,4,'Sports','NBA','Western','Northwest','Denver','Nuggets'), (22,4,'Sports','NBA','Western','Northwest','Minnesota','Timber Wolves'), (23,4,'Sports','NBA','Western','Northwest','Oaklohoma City','Thunder'), (24,4,'Sports','NBA','Western','Northwest','Portland','Trail Blazers'), (25,4,'Sports','NBA','Western','Northwest','Utah','Jazz'), (26,4,'Sports','NBA','Western','Pacific','Golden State','Warriors'), (27,4,'Sports','NBA','Western','Pacific','Los Ageles','Clippers'), (28,4,'Sports','NBA','Western','Pacific','Los Ageles','Lakers'), (29,4,'Sports','NBA','Western','Pacific','Pheonix','Suns'), (30,4,'Sports','NBA','Western','Pacific','Sacremento','Kings'), (31,4,'Sports','MLB','American','East','Tampa Bay','Rays'), (32,4,'Sports','MLB','American','East','New York','Yankees'), (33,4,'Sports','MLB','American','East','Baltimore','Orioles'), (34,4,'Sports','MLB','American','East','Toronto','Blue Jays'), (35,4,'Sports','MLB','American','East','Boston','Red Socks'), (36,4,'Sports','MLB','American','Central','Kansas City','Royals'), (37,4,'Sports','MLB','American','Central','Minnesota','Twins'), (38,4,'Sports','MLB','American','Central','Detriot','Tigers'), (39,4,'Sports','MLB','American','Central','Cleveland','Indians'), (40,4,'Sports','MLB','American','Central','Chicago','White Sox'), (41,4,'Sports','MLB','American','West','Houston','Astros'), (42,4,'Sports','MLB','American','West','Texas','Rangers'), (43,4,'Sports','MLB','American','West','Los Ageles','Angels'), (44,4,'Sports','MLB','American','West','Seattle','Mariners'), (45,4,'Sports','MLB','American','West','Oakland','Athletics'), (46,4,'Sports','MLB','National','East','New York','Mets'), (47,4,'Sports','MLB','National','East','Washington','Nationals'). (48,4,'Sports','MLB','National','East','Atlanta','Braves'), (49,4,'Sports','MLB','National','East','Philedelphia','Phillies'), (50,4,'Sports','MLB','National','East','Miami','Marlins'), (51,4,'Sports','MLB','National','Central','St. Louis','Cardinals'), (52,4,'Sports','MLB','National','Central','Pittsburg','Pirates'), (53,4,'Sports','MLB','National','Central','Chicago','Cubs'), (54,4,'Sports','MLB','National','Central','Cincinnati','Reds'), (55,4,'Sports','MLB','National','Central','Milwaukee','Brewers'), (56,4,'Sports','MLB','National','West','Los Ageles','Dodgers'), (57,4,'Sports','MLB','National','West','San Francisco','Giants'), (58,4,'Sports','MLB','National','West','Arizona','Diamondbacks'), (59,4,'Sports','MLB','National','West','San Diego','Padres'), (60,4,'Sports','MLB','National','West','Colorado','Rockies'), (61,4,'Sports','NFL','NFC','East','Dallas','Cowboys'), (62,4,'Sports','NFL','NFC','East','New York','Giants'), (63,4,'Sports','NFL','NFC','East','Philedelphia','Eagles'), (64,4,'Sports','NFL','NFC','East','Washington','Redskins'), (65,4,'Sports','NFL','NFC','West','Arizona','Cardinals'), (66,4,'Sports','NFL','NFC','West','San Francisco','49ers'), (67,4,'Sports','NFL','NFC','West','Seattle','Seahawks'), (68,4,'Sports','NFL','NFC','West','St. Louis','Rams'), (69,4,'Sports','NFL','NFC','North','Chicago','Bears'), (70,4,'Sports','NFL','NFC','North' ,'Detriot','Lions'), (71,4,'Sports','NFL','NFC','North' ,'Green Bay','Packers'), (72,4,'Sports','NFL','NFC','North' ,'Minnesota','Vikings'), (73,4,'Sports','NFL','NFC','South','Atlanta','Falcons'), (74,4,'Sports','NFL','NFC','South', 'Carolina','Panthers'), (75,4,'Sports','NFL','NFC','South','New Orleans','Saints'), (76,4,'Sports','NFL','NFC','South','Tampa Bay','Buccaneers'), (77,4,'Sports','NFL','AFC','East','Buffalo','Bills'), (78,4,'Sports','NFL','AFC','East','Miami','Dolphins'), (79,4,'Sports','NFL','AFC','East','New England','Patriots'), (80,4,'Sports','NFL','AFC','East','New York','Jets'), (81,4,'Sports','NFL','AFC','West','Denver','Broncos'), (82,4,'Sports','NFL','AFC','West','Kansas City','Chiefs'), (83,4,'Sports','NFL','AFC','West','Oakland','Raiders'), (84,4,'Sports','NFL','AFC','West','San Diego','Chargers'), (85,4,'Sports','NFL','AFC','North' ,'Baltimore','Ravens'), (86,4,'Sports','NFL','AFC','North' ,'Cleveland','Browns'), (87,4,'Sports','NFL','AFC','North','Pittsburg','Steelers'), (88,4,'Sports','NFL','AFC','North' ,'Cincinnati','Bengals'), (89,4,'Sports','NFL','AFC','South','Houston','Texans'), (90,4,'Sports','NFL','AFC','South','Indianapolis','Colts'), (91,4,'Sports','NFL','AFC','South','Jacksonville','Jaguars'), (92,4,'Sports','NFL','AFC','South','Tennessee','Titans'), (93,4,'Sports','NHL','NHL','Central','Chicago','Blackhawks'), (94,4,'Sports','NHL','NHL','Central','Colorado','Avalanche'), (95,4,'Sports','NHL','NHL','Central','Dallas','Stars'), (96,4,'Sports','NHL','NHL','Central','Minnesota','Wild'), (97,4,'Sports','NHL','NHL','Central','St. Louis','Blues'), (98,4,'Sports','NHL','NHL','Central','Winnipeg','Jets'), (99,4,'Sports','NHL','NHL','Central','Nashville','Predators'), (100,4,'Sports','NHL','NHL','Pacific','Anaheim' ,'Ducks'), (101,4,'Sports','NHL','NHL','Pacific','Arizona','Coyotes'), (102,4,'Sports','NHL','NHL','Pacific','Clagary','Flames'), (103,4,'Sports','NHL','NHL','Pacific','Edmonton','Oilers'), (104,4,'Sports','NHL','NHL','Pacific','Los Ageles','Kings'), (105,4,'Sports','NHL','NHL','Pacific','San Jose','Sharks'), (106,4,'Sports','NHL','NHL','Pacific','Vancouver','Canucks'), (107,4,'Sports','NHL','NHL','Atlantic','Boston','Bruins'), (108,4,'Sports','NHL','NHL','Atlantic','Buffalo','Sabres'), (109,4,'Sports','NHL','NHL','Atlantic','Detriot','Red Wings'), (110,4,'Sports','NHL','NHL','Atlantic','Florida','Panthers'), (111,4,'Sports','NHL','NHL','Atlantic','Montreal','Canadiens'), (112,4,'Sports','NHL','NHL','Atlantic','Ottawa','Senators'), (113,4,'Sports','NHL','NHL','Atlantic','Tampa Bay','Lightning'), (114,4,'Sports','NHL','NHL','Atlantic','Toronto','Maple Leafs'), (115,4,'Sports','NHL','NHL','Metropolitan','Corolina','Hurricanes'), (116,4,'Sports','NHL','NHL','Metropolitan','Columbus','Blue Jackets'), (117,4,'Sports','NHL','NHL','Metropolitan','New Jersey','Devils'), (118,4,'Sports','NHL','NHL','Metropolitan','New York','Islanders'), (119,4,'Sports','NHL','NHL','Metropolitan','New York','Rangers'), (120,4,'Sports','NHL','NHL','Metropolitan','Philedelphia','Flyers'), (121,4,'Sports','NHL','NHL','Metropolitan','Pittsburg','Penguins'), (122,4,'Sports','NHL','NHL','Metropolitan','Washington','Capitals')
you have a dot (.) instead of a comma (,) at the end of the line with ID 47: (47,4,'Sports','MLB','National','East','Washington','Nationals'). Change it to (47,4,'Sports','MLB','National','East','Washington','Nationals'),
You have a period at the end of this line: (47,4,'Sports','MLB','National','East','Washington','Nationals'). It should be a comma
Your error message show us, that two queries does not separated with ; Just remove Select query, or add ; after it. Then, double check syntax, or read next error message. You have points instead of comma somewhere. Your first query retrieve all data from the table. It's: SELECT * FROM `******_sports_teams` WHERE 1 It should terminated with semicolon before you call next (INSERT) query
Doctrine2 Criteria() generate wrong MySQL query
when I use \Doctrine\Common\Collections\Criteria::create() use Doctrine\Common\Collections\Criteria; ... $criteria = Criteria::create(); $criteria->where(Criteria::expr()->eq('isPublished', 1)) ->andWhere(Criteria::expr()->eq('isDeleted', 0)); $this->comments->matching($criteria) and I getting error: Message: An exception occurred while executing 'SELECT t0.id AS id1, t0.rating AS rating2, t0.text AS text3, t0.username AS username4, t0.isPublished AS isPublished5, t0.isDeleted AS isDeleted6, t0.dateCreated AS dateCreated7, t0.userIP AS userIP8, t0.user_id AS user_id9, t0.product_id AS product_id10 FROM product_comments t0 WHERE ((t0.isPublished IS ? AND t0.isDeleted IS ?) AND t0.product_id IS ?)' with params {"1":1,"2":0,"3":1123}: SQLSTATE[42000]: Syntax error or access violation: 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 '1 AND t0.isDeleted IS 0) AND t0.product_id*IS 1123)' at line 1 The problem is operand 'IS' in where clausule. It is not MySQL operand. (If I paste this query to MySQL terminal, and change "IS" => "=" - is all right) Why Doctrine genetate such query? Where is the problem?
I solved changing line 91 of Doctrine\ORM\Persisters\BasicEntityPersister from Comparison::IS => 'IS %s', to Comparison::IS => '= %s',
This is a bug in doctrine fixed by upgrading Doctrine ORM to 2.3.5 or later. Bug report at http://www.doctrine-project.org/jira/browse/DDC-2471 More discussion on the problem at https://github.com/doctrine/collections/commit/3db3ab843ff76774bee4679d4cb3a10cffb0a935#diff-757942c669bf6be9910786b2558ad745
Try replacing expr()->eq('isPublished', 1) and expr()->eq('isPublished', 0) with expr()->eq('isPublished', '?1') expr()->eq('isPublished', '?0')