Something to watch out for:
I have the following piece of code:
if (preg_match('/^(w+)(.*)$/', $text, $matches) == 0)
{
throw new Exception('debugPrepQuery parse failed for '' .
$text . "' in '$query'");
}
which throws the following exception:
debugPrepQuery parse failed for 'dist AND SubDistrict=' in 'SELECT * FROM Census1871 WHERE District=:dist AND SubDistrict=:subdist AND Division=:div AND Page=:page ORDER BY Line DESC LIMIT 1''
But since the first 4 characters in $text are obvious matches to w and .* clearly matches the remainder of the string, how can this call to preg_match fail? Why? Because when the message was displayed in the body of the HTML page it obscured the fact that there was a NEW-LINE character after "AND" and unless you add the s modifier after the closing delimiter the .* pattern match fails. That is the value of $text was "dist ANDn SubDistrict="! You have to look at the page source to see the new-lines.
برچسب:
نویسنده: آیلین رضوانی
تاريخ: سه
شنبه
10 بهمن
1396 ساعت: 16:45