According to php.net, Stack Overflow and other sources of trust, I can find 4 different ways to set UTF-8 on PDO connection, but can’t find which one is the better to choose: $pdo_db = ‘mysql:host=…
Tag: pdo
accdb and PDO php connection error
I’m trying to create a simple connection using PDO (on localhost – xampp): But then I get this error: any ideas? Answer Thanks a lot vodich, here is solution:
LIKE query using multiple keywords from search field using PDO prepared statement
Site users use a search form to query a database of products. The keywords entered search the titles for the products in the database. The search works if a user enters a single keyword, but if multiple keywords are used the query does not execute. if: $keywords = ‘apple ipod’; $search = ‘%apple% AND itemTitle LIKE %ipod%’; So the prepared
How can I access a MySQL database without using PHP PDO?
I have this script which uses PHP PDO to access the MySQL database, but the problem is my hosting provider has disabled PHP PDO, so now I’m stuck and have no idea how to change this code to access the …
PDO and MySQL ‘between’
I’m trying to get PDO to work with a MySQL ‘between’. Below is my code: What gets returned is an array with ‘0’ or ‘NULL’ for values. When I hard code the end date, it acts as if start_date is set to -1, retuning me all rows before the end_date. So, what am I doing wrong here? Answer Don’t wrap
PHP PDO access to MySQL
I went through the process of converting mysql_* code into PDO code. I’ve run it and checked that it works and everything. I just want Stack Overflow’s review of it, to make sure that I’m killing …
Using pdo in php with stored procedure
I have a simple stored procedure in MySQL database: When calling this procedure in mysql-workbench it returns the data I put in: Now when I call it from PHP using pdo I get an error: Here is my php code: Answer You need to use bindValue instead of bindParam. When you use bindParam, it binds the variable provided to the
Select on empty table but still get column names
I want to do a SELECT on an empty table, but i still want to get a single record back with all the column names. I know there are other ways to get the column names from a table, but i want to know if it’s possible with some sort of SELECT query. I know this one works when i
PDO get the last ID inserted
I have a query, and I want to get the last ID inserted. The field ID is the primary key and auto incrementing. I know that I have to use this statement: That statement works with a query like this: But if I want to get the ID using this statement: I get this error: What am I doing wrong?
PDO were rows affected during execute statement
I have found many ways to use the exec statement for PDO, but I’m not sure it helps me. My understanding is that I have to use the execute() function for prepared statements. I am updating a row with data from user input, so I would like to use a prepared statement instead of the query() call. My code is