9 2 | I am trying to find the number of rows that match a specific pattern. In this example, all that START with "123": This is working:
The problem is the LIKE will vary, so I'm trying to define it in the script, then execute the query, but this is NOT working:
How can I get this query to work properly in the second example? EDIT: I've also tried it without the period (also not working):
| ||
14 | You have the syntax wrong; there is no need to place a period inside a double-quoted string. Instead, it should be more like
You can confirm this by printing out the string to see that it turns out identical to the first case. Of course it's not a good idea to simply inject variables into the query string like this because of the danger of SQL injection. At the very least you should manually escape the contents of the variable with
Note that inside the first argument of | ||||||||||||||||||||
|
'WEB' 카테고리의 다른 글
How to set clearfix and define (0) | 2018.01.24 |
---|---|
[PHP] swtich (0) | 2018.01.23 |
explode (0) | 2018.01.22 |
[PHP] mysqli::num_rows (0) | 2018.01.14 |
[PHP] filter_var function vs number_format (0) | 2018.01.14 |
$var1 = "foo"; $var2 = "{$var1} bar"; echo $bar2;
Will output: foo bar and you don't have to worry about concatenation, etc etc. Doesn't work as you may think with single quotes for strings, however. – Blake Apr 13 '12 at 0:10