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

  • SEARCH
  • Home
  • 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 8348881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:49:16+00:00 2026-06-09T07:49:16+00:00

When I execute a pdo that specifies some but not all fields in a

  • 0

When I execute a pdo that specifies some but not all fields in a table, it inserts fine on one server, but fails to insert on the other server.

FOR EXAMPLE, ON THE PROBLEM SERVER…

With table that has three fields id, time, and intervention…

If I run this statement, it inserts as expected.

$query = "INSERT INTO data_agreements (`id`, `time`, `intervention`) VALUES (?, ?, ?)";
$q = $pdo->prepare($query);
$q->execute(array("x", "y", "z"));

But if I run the following statement, it fails to insert.

$query = "INSERT INTO data_agreements (`id`, `time`) VALUES (?, ?)";
$q = $pdo->prepare($query);
$q->execute(array("x", "y"));

The problem server is an IIS with MySql 5, PHP 5.2.6. On a different server Apache with MySql 5, PHP 5.2.6, both statements insert as expected. So I am wondering if there is some MySQL install/setting that I need to set on the problem server to tell it to accept statements that specify only a subset of fields in a table. ?

Thanks!

  • 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-09T07:49:18+00:00Added an answer on June 9, 2026 at 7:49 am

    I bet column intervention do not allow null values.

    try to alter the table and see if it works:

    ALTER table data_agreements Modify intervention varchar(50) null DEFAULT '';
    

    and try to execute again the query. I assumed that intervention is string but, of course, you can modify it that fits your needs.

    Thanks.

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

Sidebar

Related Questions

I execute some tests within my application, but before doing that I have to
All, I have some PHP PDO code that looks like this: <?php ... $query=$dbh->prepare(SELECT
I have some pages that make PDO queries using prepare() and execute() (binding some
I'm trying to update my database table with PDO, but to avoid security leaks,
I have a set of PDO statements that do not seem to be working.
I'm using PDO and was under the impression that prepare escaped apostrophes but I
I'm sure that's a real easy one, but I begin with php and can't
It has long been known that PDO does not support COUNT(*) and a query
The PDO transaction examples at PHP.net show that PDO::exec() is transactioned, but there are
Should I use php PDO or normal mysql_connect to execute database queries in PHP?

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.