Php Regex to find if string is mysql select statement
问题 I'm trying to validate queries before executing them, If query is not a mysql select statement then i have to show message to user. I found below regex from this link: Validate simple select query using Regular expression $reg="/^Select\s+(?:\w+\s*(?:(?=from\b)|,\s*))+from\s+\w+\s+where\s+\w+\s*=\s*'[^']*'$/i"; next i wrote below code but it always prints not select query ($match is empty every time) $string="select * from users where id=1"; preg_match_all($reg,$string,$match); if(!empty(