Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

275
Views
Problem with PDO WHERE when using VARCHAR-columns in SQL Server

We are upgrading our MS SQL Server from SQL Server 2012 to the current version. We are using PDO with M$ ODBC driver running on CentOS Linux. PHP version is 7.4.

The problem is that if there is a (prepared) condition like

WHERE variable = ? 

and variable is of type VARCHAR there comes an error

[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The data types varchar and text are incompatible in the equal to operator

An example code is like this:

$stmt = $db->prepare("SELECT * FROM Users WHERE user_login = ? AND user_application  = ?");
$stmt->execute([$login, $app]);

user_login and user_application are both VARCHAR-columns and $login and $app normal PHP string variables.

It wasn't a problem with the previous SQL server, the comparison went OK. I don't want to go through all the codebase to circumvent this in myriads of places - so - is there some setting somewhere (SQL server, ODBC-driver, PHP config, ...) where to set things "right" again?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Seems, it was sort of privileges error after the database migration. I removed the user that had come from restore operation and granted correct privileges again. Only, I am quite positive, I had done it already once. And I think there was no login errors when trying to use the database.

Sorry for dumb question. Though, I have always said, that there are no dumb questions, just dumb askers...

hank

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!