No, you don’t need the inner single quotes so just $term = "$term%";
The statement you’re running now would try to match 'a%'
instead of a%
bindParam will make sure that all string data is automatically properly quoted when given to the SQL statement.
More Related Contents:
- PDOException SQLSTATE[HY000] [2002] No such file or directory
- PDO get the last ID inserted
- PDO mysql: How to know if insert was successful
- MySQL check if a table exists without throwing an exception
- Fetching single row, single column with PDO
- Replacing mysql_* functions with PDO and prepared statements
- PDO::PARAM for type decimal?
- Gather column name of a table from database [closed]
- I am seeing this error on submitting form Error: query was empty [closed]
- How to convert the json image url string into Bitmap image to display images in android application
- Insert form in MySQL with PDO [duplicate]
- Undefined index $_POST
- How to check if a row exists in MySQL? (i.e. check if username or email exists in MySQL)
- How to use multiple databases in Laravel
- Getting raw SQL query string from PDO prepared statements
- How do I set ORDER BY params using prepared PDO statement?
- Show values from a MySQL database table inside a HTML table on a webpage [duplicate]
- “Invalid parameter number: parameter was not defined” Inserting data
- How can I store and retrieve images from a MySQL database using PHP?
- Having issue with matching rows in the database using PDO
- How can I properly use a PDO object for a parameterized SELECT query
- How do I return integer and numeric columns from MySQL as integers and numerics in PHP?
- Real escape string and PDO [duplicate]
- Mechanisms for tracking DB schema changes [closed]
- SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax — PHP — PDO [duplicate]
- PDO Connection Test
- PHP PDO vs normal mysql_connect
- Can I create a database using PDO in PHP?
- PDO error: SQLSTATE[HY000]: General error: 2031
- Is a BLOB converted using the current/default charset in MySQL?