How to put variables in the MySQL query statement? Guys
x梦
x梦 2021-11-25 04:42:31
0
6
978

I want to use php to query the database, but I have to add a variable to the condition

"select lyrics, song title, pinyin from name where pinyin like '%$cp[a-z]%'"

In this way, an error is reported directly. If you don’t add [a-z], there is no problem, but you must add it to query. What should I do? Guys

x梦
x梦

reply all(2)
逆旅行人

In my impression, [] seems to be a regular thing. It doesn’t seem to be mentioned in the fuzzy query. You can try it

逆旅行人

select lyrics, song title, pinyin from name where pinyin like '%$cp%' and pinyin REGEXP '[a-z]'

  • reply Brother, is there any way to make the variable followed by a letter a-z? This method can only find the data containing $cp and a-z.
    x梦 author 2021-11-26 03:59:39
  • reply Okay, just put the variable in the regular expression
    autoload author 2021-11-26 08:51:02
  • reply Then you don't need to perform fuzzy query "select lyrics, song title, pinyin from name where pinyin REGEXP `$cp[a-z]`"
    autoload author 2021-11-26 08:58:12
  • reply No, brother, he will think that $cp[a-z] is an array variable and treat [] as a subscript. Parse error: syntax error, unexpected '-', expecting ']' in /www/wwwroot/xx.yuefenxiang.cn/ cs/fkyy.php on line 387. In the code, $cp[a is directly the color of the variable.
    x梦 author 2021-11-26 18:15:56
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template