Skip to main content

All Questions

Tagged with
0 votes
3 answers
12k views

SQLSTATE[28000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user

I'm using the following PHP connection file to connect to my SQL Server database. <?php $servername = "..."; $username = "..."; $password = ""; $dbname = "...&...
0 votes
0 answers
40 views

Why PDO::FETCH_CLASS is working with small results and does not work with large results?

I'm trying to convert my SQL result into a class using PDO::FETCH_CLASS. The code was working fine, until I encountered a query that generates 83 rows. The query returns two columns, one of type int ...
-2 votes
0 answers
52 views

Why do i get PHP source code and bad chars via SQL output?

Normally i don't have big issues programming PHP and SQL, but i can't really figure out what causes this little bug. I have a page using PHP and fetching data from a MSSQL server. I use PDO functions ...
4 votes
2 answers
1k views

Define encoding when using PDO ODBC SQL Server connection?

I connect to a SQL Server using like this: $pdo = new PDO("odbc:DRIVER=ODBC Driver 17 for SQL Server;SERVER=$serverName;DATABASE=$dbName", $username, $password); The PDO instance is created,...
1 vote
1 answer
178 views

Link 2 Firebird databases with PDO

Short summary. I have 2 databases (Invoices.gdb and Users.gdb) I want to get a table where I can see which Invoice is linked to which customer. For your info: I know the PHP code to get my values into ...
3 votes
1 answer
619 views

Laravel 8: Cannot set PDO::ATTR_TIMEOUT

I am trying to set the PDO::ATTR_TIMEOUT to 10 seconds, but the change is not persisting. The timeout is stuck at 2 seconds no matter what I try. config/database.php: 'mysql' => [ ...
-1 votes
0 answers
46 views

Using a _generator_ to loop through and update the SAME table in PDO [duplicate]

To minimize my memory usage and simplify my code, I wanted to use a generator to loop through a table. But when I update that same table, the generator no longer works as expected. public function ...
278 votes
9 answers
101k views

Can PHP PDO Statements accept the table or column name as parameter?

Why can't I pass the table name to a prepared PDO statement? $stmt = $dbh->prepare('SELECT * FROM :table WHERE 1'); if ($stmt->execute(array(':table' => 'users'))) { var_dump($stmt->...
4 votes
4 answers
36k views

How to prevent SQLITE SQLSTATE[HY000] [14]?

I receive sometimes the following error: SQLSTATE[HY000] [14] unable to open database file I open the datebase by using new PDO("sqlite:database/datbase.db","","",array( PDO::...
0 votes
1 answer
147 views

Query Join table to sort by menuindex

Here is my query: $results = $modx->query("SELECT contentid FROM modx_site_tmplvar_contentvalues WHERE tmplvarid=107"); I need to sort it by menuindex so i tried this: $results = $modx-&...
1 vote
1 answer
56 views

Displaying bread crumbs array keyed to number of segments

I just converted a query that displays "bread crumbs" style navigation links to PDO: function get_path($dbh,$node,$TopnavTable, $TopnavName) { $stmt = $dbh->prepare("SELECT name FROM $TopnavTable ...
0 votes
0 answers
37 views

Doctrine\DBAL\Driver\PDO\Statement::__construct(): Argument #1 ($stmt) must be of type PDOStatement, null given

I am getting a very unexpected and unusual error that is kinda hard to trace. I'm thinking this might be actually covering some other, maybe driver level issue? This is Postgres on gcloud, PHP-fpm POD,...
1 vote
0 answers
49 views

How to Enhance Security Against SQL Injection in PHP with PostgreSQL? [duplicate]

I've implemented a PHP script to handle form submissions and insert data into a PostgreSQL database. However, I'm concerned about the potential security vulnerabilities, particularly SQL injection. ...
179 votes
25 answers
211k views

PDO Prepared Inserts multiple rows in single query

I am currently using this type of SQL on MySQL to insert multiple rows of values in one single query: INSERT INTO `tbl` (`key1`,`key2`) VALUES ('r1v1','r1v2'),('r2v1','r2v2'),... On the readings on ...
0 votes
1 answer
209 views

How is my Ajax PHP filter not filtering records with PDO? [duplicate]

So I am trying to filter records using checkboxes with Ajax and PHP. I am trying to filter records with PDO, since it is the safest option. I am wondering why the filter system only filters when one ...

15 30 50 per page