Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8164775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:23:28+00:00 2026-06-06T19:23:28+00:00

I have a pdo connection with ODBC (v2000.86.359.00) connecting to an SQL Server (v8.00.2039

  • 0

I have a pdo connection with ODBC (v2000.86.359.00) connecting to an SQL Server (v8.00.2039 SP4 Standard Edition) database.

This works:

$id = 486;
$duedate = 'June 27, 2012';
$query ="INSERT into AssetHistory (AssetID, DateDue) Values($id, $duedate);";                   
$noParams = $db->exec($query);
$db->query($query);

But if I try to use a prepared statement like this:

$sql = 'INSERT into AssetHistory 
    (AssetID, DateDue)
    Values(:id, :duedate);';                

$input = array(':id'=>486, ':duedate'=>'June 27, 2012');
$smt = $db->prepare($sql);
$smt->execute($input);

I get this error (from $smt->errorInfo()):

 "[Microsoft][ODBC Driver Manager] Function sequence error (SQLExecute[0] at ext\pdo_odbc\odbc_stmt.c:254)"

I’ve tried:
1) Enclosing :duedate in single quotes
2) Binding date to unix timestamp integer
3) Binding :duedate to php DateTime object
4) Inserting just $duedate into the sql statement before preparing

At this point I might be stuck using the $db->query method and sanitizing inputs as best I can, but I would really appreciate any suggestions.

Using PHP 5.38 on a Windows Server 2003 box.

Updates:
I’ve removed some of the variables from a previous version of this question. The error message has changed, but the end result is the same.

I’ve also tried manually binding the parameters like so:

$smt->bindValue(':id', 486, PDO::PARAM_INT);
$smt->bindValue(':duedate', 'June 27, 2012', PDO::PARAM_STR);

Along with adding the convert function to the sql like so:

$sql = 'INSERT into AssetHistory 
   (AssetID, DateDue)
Values(:id, convert(datetime,:duedate, 100));';

Which returns:
“COUNT field incorrect or syntax error “

And I’ve noticed that SQL Server doesn’t really play nice with unix timestamps…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T19:23:29+00:00Added an answer on June 6, 2026 at 7:23 pm

    Finally resolved this by downloading and installing both the sqlsrv php drivers (I used version 2.0) and the SQL Server 2008 Native Client.

    With a little tweak to the $dsn parameter, the rest of the code works like magic — no binding, converting or casting required.

    I ended up only using the php_pdo_sqlsrv_53_ts_vc9.dll, but make sure you select the correct thread-safe/ non-thread safe version of the driver, as the wrong dll in you php.ini will crash your server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am connecting to FileMaker Pro 11 Server with a ODBC Connection. I am
I have just changed my database connection. I am not used to the PDO
I am running problems in implementing LIKE in PDO I have this query: $query
I am going through this tutorial about PDO and have come to the point
I have following code for inserting data into database using PDO. It inserts data
I have this old-style non-PDO MySQL query (the code isn't tightened up, just to
I am using php PDO and I have this error when I use the
Using SQLite in PHP (thus using PDO), I have this code: try { $db
I have connection.php file where i am initializing PDO in the $db. And i
So I have this problem when I run a script with PHP PDO that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.