All Questions
22,171 questions
-1
votes
1
answer
53
views
PHP PDO fetchObject returns duplicated properties, half of them null [closed]
I'm trying to learn PHP and MySQL. I've got a database and some retrieval happening, but when I used fetchObject() I get 2 instances returned. First tried:
class Food {
// Properties
public $id;
...
0
votes
0
answers
41
views
Why the error message "Call to a member function execute()" is not suppressed in try-catch? [duplicate]
I have the code:
try {
$db = new PDO("sqlite:filename.db");
$q = $db->prepare("SELECT p1 FROM T1;");
$q->execute(); // Fatal error: Uncaught Error: Call to a ...
-1
votes
0
answers
43
views
Pdo: alter table ıf not exısts [duplicate]
I want to say do nothing if there is a column in the table, otherwise add the column, but I couldn't do it.
I want to do this with PHP and PDO.
This works. But it doesn't check if the column exists in ...
1
vote
0
answers
74
views
Index not being used depending on parameter binding & charset
Question
Why is my index being ignored under certain circumstances, causing slow execution times. I tracked down the cause to a combination of the use of UNION ALL + chosen PHP database API + selected ...
0
votes
1
answer
95
views
MySQL deadlock when using SELECT FOR UPDATE SKIP LOCKED?
I have a queue system built using PHP and MySQL (I initially built it using redis, but it was kinda complicated and not very flexible), and after doing some research I found out that since MySQL 8.0.1,...
0
votes
1
answer
42
views
Pdo sqlsrv. unable to connect (login timeout expired) to microsoft Sql Server on php 8 and Rocky Linux 9
I got a cPanel installed on Rocky 9 Linux and I need to connect to SQL Server 2019 from PHP (8.1).
I installed the driver using this: https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/...
-2
votes
0
answers
36
views
PDO login will only take me to error screen [duplicate]
I'm trying to make a login screen that'll connect a user to a PHP database. I've created three files "login.php", "login-action.php", and "admin-dashboard".
Unfortunately,...
-1
votes
1
answer
40
views
Consistent Access Denied error when trying to connect to MySQL DB with PDO [duplicate]
I'm newbie to PHP and I'm trying to get started with it.
I have been following this guide to create a PHP boilerplate for future projects using Docker (I didn't want to use XAMPP cause I like to make ...
0
votes
2
answers
48
views
PDO pgsql: fetch bytea column
In PostgreSql there is a table with a column of type 'bytea' with jpeg.
In pgAdmin this column is displayed as [binary data].
In php script I need to get binary data from this column and translate it ...
0
votes
2
answers
133
views
Why there is a difference between PDO::lastInsertId and Mysql's LAST_INSERT_ID() behavior? [closed]
My current development environment is PHP 7.2.
This is MariaDB 10.3.11.
When using PDO's lastInsertId function, if you run another query after the insert query, the lastInsertId result value will ...
-4
votes
1
answer
42
views
Why I'm getting error when using LIMIT with PDO [duplicate]
here my code :
$Limit=5;
$sql = 'SELECT * FROM [dbo].[table_name] ORDER BY [count] DESC LIMIT :limit';
$stmt = $db->prepare($sql);
$stmt->bindValue(':limit', (int) $Limit, PDO::PARAM_INT);
$...
-1
votes
1
answer
29
views
PDO errors don't display [duplicate]
Sorry, I'm new to PDO and rusty with PHP. I have a PHP page where I'm trying to display error messages when a PDO call fails. Here's what I have but not even the echo statements after the failure ...
0
votes
0
answers
89
views
php pdo display/refer to previous row
I am trying to send an email with PHP mailer (works ok) but when i try to implement a feature to show the name of the previous user that received the email, it does not display the name. here is my ...
1
vote
0
answers
25
views
PDO_ODBC not returing same data as odbc_* functions
I'm not able to return same data with PDO functions and with ODBC_* functions. With the same driver.
The database is SAP HANA.
Code:
$driver = 'HDBODBC';
$host = "XX.XX.XX.XX:...
1
vote
0
answers
32
views
could not find driver using laragon
I’m working on an OOP project with Laragon locally. I configured my database using environment variables that I placed in a Constant.php file. I also created a User model to establish the database ...
1
vote
1
answer
78
views
Error in a PHP PDO connection with Firebird 2.5
I'm trying to connect and get some data from a Firebird 2.5 database. I use PHP 8.0.30 with XAMPP.
$query = "SELECT FIRST 2 PG.PRODUTOGRADE_IDENTIFICADOR AS ID, P.PRODUTO_DESCRICAO AS PRODUTO, ...
0
votes
0
answers
29
views
PDO driver mysql is not supported displays while running an Admidio-based project's container
Recently I tried to fabricate a Docker container in my Admidio-based web application, but I encountered to a tiny error:
When I open the localhost:8080 web page it displays the following message:
&...
1
vote
0
answers
38
views
The bound variable does not change after execute() per example #5 PDO Stored Procedures in the PHP Documentation, [duplicate]
I've been doing what I'm about to explain using ASP classic and ASP.Net with MSSQL Server for all that time and it works beautifully!
Please, read carefully. Example #5 comes from here: https://www....
0
votes
0
answers
51
views
Don't bind PDOStatement 'NOW()' as timestamp [duplicate]
I've faked the NOW() function in my postgresql database so it returns a set date using this answer that modifies the user's search path. I'm using a MVC library and can see the queries it's sending ...
-1
votes
1
answer
173
views
PDO changed behaviour for automatic transactions with PDO in PHP 8
I recently came across some code I have not touched for a while, but wanted to run it. And it failed, although I am almost sure it used to work. So I investigated, and it turns out: it is the ...
0
votes
0
answers
53
views
PHP 7.3, Windows Server 2016, SQL Server 2017, PDO: error "No ODBC error was found"
I'm getting an error inconsistently.
try {
$this->db = new PDO("sqlsrv:Server=" . $core->server . ";Database=webcontent;", $uid, $pwd);
$this->db->...
0
votes
0
answers
45
views
Why I get Syntax error when I prepare statement for dropping a Db? [duplicate]
In my code I try to drop a database:
$connectionString="mysql://...";
$pdo = new PDO($connectionString);
...
// I intentionally Drop the Db from the user-given db name
// Details ...
0
votes
0
answers
72
views
Issue with mdb-tools and empty string date time fields
I'm have a .mdb access database with [table1] with [field1] as a datetime type.
I use php pdo and mdb-tools to access the database.
I use php strototime function to build sql statements to get rows ...
0
votes
1
answer
87
views
How import also column name in CSV file [closed]
I have this code that works perfectly to export a table to a CSV file, but it does not insert header column name.
<?php
$host = 'host';
$mydatabase = 'db';
$user = 'user';
$pass = 'pass';
try {
...
1
vote
0
answers
154
views
SSL Provider Error with ODBC Driver 18 for SQL Server in Laravel 11 Docker Setup
I’m encountering an SSL error when trying to connect to SQL Server using ODBC Driver 18 in a Laravel 11 application running in a Docker container with PHP and Apache. Here are the details:
Dockerfile
...
1
vote
0
answers
51
views
How to set a session variable for a PDO object with DenodoODBC?
I’m working with large queries and long fields created using the GROUP_CONCAT function. The results of my queries appear to be truncated. After some research, I found that the group_concat_max_len ...
0
votes
0
answers
24
views
PHP function made to query database returning three times more results [duplicate]
I wrote a function to query a database and return an array that contains the results. The issue is the function is returning 3x the results in the array when it returns a result. In the case below, ...
0
votes
0
answers
70
views
Browser and CLI have Different php_pdo_pgsql Extension Versions
I seem to have a very weird issue where the version of my php_pdo_pgsql extension when used through CLI is different to the version used in the browser.
Current setup:
OS: Windows 11
PHP Version: 8.1....
0
votes
0
answers
23
views
How to use a custom port with PHP Mysql PDO using user@localhost [duplicate]
I have to make a PDO connection using these constraints:
The mysql user I have is in format user@localhost
I need to open a connection on MaxScale, then I need a custom TCP port
I cannot use socket ...
0
votes
0
answers
33
views
PHP PDO ODBC getColumnMeta: native_type is missing in result array
I need to find out the column type of columns in a query:
$columnmeta = $stmt->getColumnMeta($column);
In the resulting array the native_type is missing, there is only pdo_type, which is pretty ...
0
votes
0
answers
33
views
How to prevent PDO prepared query to bind parameters with quotes [duplicate]
I have an old script of mine that I had to migrate from mysqli to PDO.
The following works great in the old way, but produces unwanted results in the new because of quotes being added to the query ...
0
votes
0
answers
29
views
Failed to query data using WHERE and IN clause on PHP MySQL with multiple ID [duplicate]
I'm using pure PHP and MySQL. And I'm a beginner PHP developer.
Let say I have this string that contains some IDs
$string = "123,46,78,000";
And I would like to query data by using this ...
0
votes
1
answer
62
views
Can get emojis to show in PHP with MySQL 5.x, but not 8.x
I have a PHP 7.3 project that's currently using MySQL 5.5, with utf8 tables. Some of the tables contain emoji data, which show up fine in the current project. I'm trying to update the project to MySQL ...
0
votes
1
answer
67
views
PDO errorInfo() on ERRMODE_SILENT no longer reports errors after upgrading past PHP 8.1.7
We recently upgraded our PHP version to 8.3.10 from 8.1.0, and found that errors were no longer being reported when a query fails.
We use the PDO class to interact with out postgreSQL (version 13.15) ...
1
vote
1
answer
109
views
Why is an intarray operator not available when the query is called using PDO?
PostgreSQL version 14
I have a query behaving differently when run from pgAdmin than it does when run from PHP.
SELECT * FROM UNNEST('{1,2,3,4,5}'::integer[] - '{2,4}'::integer[])
When I run this ...
0
votes
1
answer
63
views
error while running my php laravel program
Illuminate\Database\QueryException
could not find driver (Connection: mysql, SQL: select * from `site_settings` order by `created_at` desc limit 1)
at vendor\laravel\framework\src\Illuminate\...
0
votes
0
answers
36
views
PHP Firebird unable to locate
I'm not being able to locate the pdo_firebird, even tho the file is in the correct directory.
Error message:
PHP Startup: Unable to load dynamic library 'pdo_firebird' (tried: C:\php-8.2.22\ext\...
1
vote
1
answer
53
views
PHP PDO error - SQLSTATE[HY093]: Invalid parameter number
could someone have a look at my code and help me figure out what is causing the error in my PDO query.
The query works fine when I search by "Department", "Datarange", "...
0
votes
1
answer
81
views
INSERT only if row with specific conditions does not exist - with some concerns about concurrency and atomicity
I need to insert a row in a table only if a row with a specific set of conditions is not already found in that table.
Given that this problem is (extremely) common, I searched through answers and came ...
0
votes
0
answers
38
views
PDO MySQL 5.6 Query Execution Timeout [duplicate]
Going through threads from 2009-2022 it doesn't look like there has been a real answer on getting a query to timeout in PHP from MySQL (5.6). The PDO timeout attribute is for the connecting, not the ...
0
votes
1
answer
80
views
In Docker: Fatal error: Uncaught PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cinema.movies' doesn't exist in
I tried to build a container for a PHP-apache app with MariaDB and PhpMyAdmin and i receive the error:
Fatal error: Uncaught PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table '...
0
votes
0
answers
44
views
web aplication using php pdo fulltext search delivers result on ubuntu system but not on windows system; identical DB on both
The setting
Windows 11
Server-Version: 8.4.0 - MySQL Community Server - GPL
Apache/2.4.61 (Win64) PHP/8.3.8
Ubuntu
Server-Version: 10.3.39-MariaDB-0ubuntu0.20.04.2 - Ubuntu 20.04
Apache/2.4.41 (Ubuntu)...
0
votes
0
answers
19
views
PHP PDO Query is not returning any results despite SQL query running correctly in MySQL Workbench [duplicate]
I am working on some PHP code where I take a comma seperated string from a user table, and seperate it into a comma seperated string to be inserted into another SQL query to pull the comma seperated ...
0
votes
0
answers
121
views
pdo_sqlite extension error Module "sqlite3" is already loaded
I successfully installed PHP 8.2 on a Raspberry Pi 4 and installed the SQLite extensions through apt. I uncommented the correct lines in php.ini. My PHP scripts can read SQLite files but can't write ...
0
votes
1
answer
77
views
Not able to show a pdf / image from binary data in MSSQL using PDO LOB
I go MSSQL database which contains attachments - most of them are PDFs. I want to create simple website, that will display attachment after clicking a button. I got main website prepared (there are ...
-3
votes
1
answer
42
views
PHP XAMPP Config [closed]
I try to connect my php website with a XAMPP Server so I can access my MySQL database. Any Ideas how the config has to look like, because I'm rather stuck with this one.
I tried to make a config but ...
0
votes
0
answers
63
views
Informix PDO assoc_id error SQLSTATE=HY000, SQLDriverConnect: -25546
It has been about half a year that we have been facing an error on our production server. At the beginning it happened every 2-3 months, but last Friday it happened again and today once again. We have ...
0
votes
0
answers
21
views
SQLSTATE[HY000] [2002] No connection could be made because the target machine was selected [duplicate]
I'm trying to connect my windows machine with xampp, using php with PDO, to a server on the local network (Linux)
<?php
$dbname = "DBNAME";
$user = "USERNAME";
$pass = "...
10
votes
10
answers
3k
views
Possible bug with PHP PDO and with PostgreSQL
At the startup of the docker application (with laravel php), for 1 request, connection to database is fine. After the first request I start to get this error.
SQLSTATE[08006] [7] could not send SSL ...
1
vote
1
answer
316
views
PHP is not reading .env file
I am using PHP with PDO to connect to my database.
I want to start using environment variables, so I used the following terminal command:
composer require vlucas/phpdotenv
My .env file now contains ...