我的正則表達式foo是不是最好的,但下面不工作,我正在尋找一個小小的建議:REGEXT在MySQL查詢
$query = $_GET['indicator'];
// given: 239,240 or 240,239 or 238,239,240
// and: 239, 240 or 240, 239 or 238, 239, 240
// and: 239
// we need to check for start+number+puntuation(1), punctuation+number+end(2), punctuation+number+punctuation(3)
// space+number+end(4), space+number+punctuation(6)
// start+number+end(6)
$sql = 'SELECT * from reports WHERE dataSetIDs REGEXP \'';
$sql .= '^'.$query.'[:punct:]|'; // 1
$sql .= '[:punct:]'.$query.'$|'; // 2
$sql .= '[:punct:]'.$query.'[:punct:]|'; // 3
$sql .= '[:space:]'.$query.'$|'; // 4
$sql .= '[:space:]'.$query.'[:punct:]|'; // 5
$sql .= '^'.$query.'$\''; // 6
$result = mysql_query($sql);
查詢正在注視哪個具有CSV特定的細胞格式化的一組數字格式沒有設置(即逗號後面可能有空格)。我得到的只有一個條目的行...但不是在csv中有數字的行。
任何指針非常讚賞。
乾杯,
大教堂
-1 SQL注入漏洞:看http://stackoverflow.com/questions/332365/xkcd-sql-injection-please-explain(但出票) – Johan 2011-05-28 20:51:10