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 8865267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:27:41+00:00 2026-06-14T16:27:41+00:00

Can you send more parameters than needed to a prepared statement using PDO with

  • 0

Can you send more parameters than needed to a prepared statement using PDO with no undesired side effects?

That mights seem like a strange question but I ask because I have 4 queries in a row which all use similar and different parameters. The relevant parts of the queries:

1st (select, different table to others):
WHERE threadID = :tid

2nd (select):
WHERE user_ID = :u_ID AND thread_ID = :tid

3rd (update if 2nd was successful):
SET time = :current_time WHERE user_ID = :u_ID AND thread_ID = :tid

4th (insert if 2nd was unsuccessful):
VALUES (:u_ID, :tid, :current_time)

Can I declare one array with the three parameters at the beginning and use it for all 4 queries?

To sort out any confusion, the queries would be executed seperately. It is the parameters variable being reused and so that would mean some queries would receive parameters they don’t need. So something like:

$parameters = array(':tid' => $tid, ':u_ID' => $u_ID, ':current_time' => $time);

$1st = $db->prepare($query1);
$1st->execute($parameters);

$2nd = $db->prepare($query2);
$2nd->execute($parameters);

$3rd = $db->prepare($query3);
$3rd->execute($parameters);

$4th = $db->prepare($query4);
$4th->execute($parameters);

If I can, should I? Will this slow down or cause security flaws to my database or scripts?

If I can make this question a bit clearer, please ask.

Thank you!

  • 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-14T16:27:42+00:00Added an answer on June 14, 2026 at 4:27 pm

    I got a chance to test my question, and the answer is you cannot send more parameters than the query uses. You get the following error:

    PDOException Object
    (
        [message:protected] => SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
        [string:Exception:private] => 
        [code:protected] => HY093
        [file:protected] => C:\Destination\to\file.php
        [line:protected] => line number
        [trace:Exception:private] => Array
            (
                [0] => Array
                    (
                        [file] => C:\Destination\to\file.php
                        [line] => line number
                        [function] => execute
                        [class] => PDOStatement
                        [type] => ->
                        [args] => Array
                            (
                                [0] => Array
                                    (
                                        [:u_ID] => 1
                                        [:tid] => 1
                                        [:current_time] => 1353524522
                                    )
    
                            )
    
                    )
    
                [1] => Array
                    (
                        [file] => C:\Destination\to\file.php
                        [line] => line number
                        [function] => function name
                        [class] => class name
                        [type] => ->
                        [args] => Array
                            (
                                [0] => SELECT
                                                    column
                                                FROM
                                                    table
                                                WHERE
                                                    user_ID  = :u_ID AND
                                                    thread_ID = :tid
                                [1] => Array
                                    (
                                        [:u_ID] => 1
                                        [:tid] => 1
                                        [:current_time] => 1353524522
                                    )
    
                            )
    
                    )
    
            )
    
        [previous:Exception:private] => 
        [errorInfo] => Array
            (
                [0] => HY093
                [1] => 0
            )
    
    )
    

    I don’t know a huge amount about PDO, hence my question, but I think that because :current_time is sent but not used and the error message is “Invalid parameter number: parameter was not defined” you cannot send extra parameters which are not used.

    Additionally the error code HY093 is generated. Now I can’t seem to find any documentation explaining PDO codes anywhere, however I came across the following two links specifically about HY093:
    What is PDO Error HY093
    SQLSTATE[HY093]

    It seems HY093 is generated when you incorrectly bind parameters. This must be happening here because I am binding too many parameters.

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

Sidebar

Related Questions

I have observed that when I add more than 18 parameters to a Play
How can you disable the send -button if there is one or more input
I can send requests to friends using Multi Friend Request Selector inside my Page
I know that soap can send XML over http, is there any way to
Using cURL I can send a GET request with a body. Example: curl -i
How can I pass more than one parameter from jQuery to an ASHX file.
I can find a way to send parameters to my activity from my notification.
i want to send more than one parameter to servlet through anchor tag .
Is there a way which I can return more information to the caller that
How this UIButton rewind can send notification to UIButton play to perform playpauseaction method

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.