It can work with bind param too in following way:
$name = "%$name%";
$query = $dbh->prepare("SELECT * FROM `gc_users` WHERE `name` like :name");
$query->bindParam(':name', $name);
$query->execute();
More Related Contents:
- PHP – Using PDO with IN clause array
- Can I use a PDO prepared statement to bind an identifier (a table or field name) or a syntax keyword?
- Insert multiple rows with PDO prepared statements
- Replacing mysql_* functions with PDO and prepared statements
- PDOstatement (MySQL): inserting value 0 into a bit(1) field results in 1 written in table
- Calling stored procedure with Out parameter using PDO
- When *not* to use prepared statements?
- PDO error: SQLSTATE[HY000]: General error: 2031
- Use of PDO in classes [duplicate]
- Error while using PDO prepared statements and LIMIT in query [duplicate]
- How to apply bindValue method in LIMIT clause?
- Row count with PDO
- PDO get the last ID inserted
- How do I use password hashing with PDO to make my code more secure? [closed]
- MySQLi prepared statements error reporting [duplicate]
- How to view query error in PDO PHP
- Resetting array pointer in PDO results
- Get last insert id after a prepared insert with PDO
- Do SQL connections opened with PDO in PHP have to be closed
- What is the advantage of using try {} catch {} versus if {} else {}
- Alternative for mysql_num_rows using PDO
- ERROR: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it
- Unknown database error in PHP but it exists in PHPMyAdmin
- How do detect that transaction has already been started?
- return one value from database with mysql php pdo
- Trying to access array offset on value of type bool
- return multiple response data in one response
- How to get a query error from prepare() in PDO PHP?
- How can I pass an array of PDO parameters yet still specify their types?
- PHP PDO how to run a multiple query request?