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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:34:55+00:00 2026-05-29T17:34:55+00:00

<?php require_once includes/db_data_inc.php; try { /* In this way I get a db connection

  • 0
<?php

require_once "includes/db_data_inc.php";

try 
{
    /* In this way I get a db connection handle */
    $DBH = new PDO("mysql:host=$db_host;port=8889;dbname=$db_name",$db_user,$db_pass);

}
catch (PDOException $pdoe) 
{
    error_log($pdoe->getMessage());
    die("Failed to connect to the database.");
}

$DBH->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$DBH->setAttribute(PDO::ATTR_AUTOCOMMIT,false);

try
{
    $success_msg = NULL;
    $unsucess_msg = NULL;

    $query = "INSERT INTO users (name,surname,address,birth_place,province,birthdate,sex,treatment) VALUES (?)";
    $SHT = $DBH->prepare($query);

    $SHT->bindParam(1, $_POST['name']);
    $SHT->bindParam(2, $_POST['surname']);
    $SHT->bindParam(3, $_POST['address']);
    $SHT->bindParam(4, $_POST['birth_place']);
    $SHT->bindParam(5, $_POST['province']);
    $SHT->bindParam(6, $_POST['dt']);
    $SHT->bindParam(7, $_POST['gender']);
    $SHT->bindParam(8, $_POST['select']);

    $DBH->beginTransaction();

    if($SHT->execute())
    {
        $DBH->commit();
        $success_msg = "The emergency call was correctly sent...";
    }
    else
    {
        $unsucess_msg = "It couldn't estabilished a connection to call center...";
    }
}
catch(PDOException $pdoe)
{
    $DBH->rollBack();
}


/* Close the db connection */
$DBH = null;

?>

here it is my mysql connection function to connect to mysql db and an insert query. The code doesn’t work.There is maybe some error?Because I don’t receive any error from php console but I don’t even see any result in the page.any idea?

I worked on the console and obtained this error:

Invalid parameter number: number of bound variables does not match number of tokens

what does it mean?

  • 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-05-29T17:34:57+00:00Added an answer on May 29, 2026 at 5:34 pm

    One ‘?’ just doesn’t match with the eight parameters you pass in later.

    Take a look at the examples of the PDOStatement::bindParam method.

    Use something like:

    $query = "INSERT INTO users (name,surname,address,birth_place,province,birthdate,sex,treatment) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<?php ini_set('display_errors',1); error_reporting(E_ALL); require_once('/include/adLDAP.php'); $adldap = new adLDAP(); $username = user123; $password = pass123;
I have some files: core.php : require_once 'logger.php'; require_once 'smth_else.php'; $Logger = new Logger();
I add this class to library/My/Validate/PasswordConfirmation.php <?php require_once 'Zend/Validate/Abstract.php'; class My_Validate_PasswordConfirmation extends Zend_Validate_Abstract {
What is better practice for script performance tuning? This one? require_once(db.php); if (!is_cached()) {
I've a problem with PEAR (PHP). This is the error: Warning: require_once(DB.php): failed to
<? require_once('includes/inc_auth2.php'); require_once('includes/config.php'); authRegister($Tawanda, $Mukoko, $dob, $gender, $email, $password); //requesting from database /*require_once('includes/db.php'); function
guys!I got a littile trouble. There is connection.inc.php in includes folder: <?php function dbConnect($usertype,
Getting this error: Fatal error: require_once() [function.require]: Failed opening required 'db/db.php' (include_path='/home/domain.ru/testerier/sites/application/../library:/home/domain.ru/testerier/sites/library:.:/usr/local/lib/php;/home/domain.ru/testerier/sites/application/models') in /home/domain.ru/testerier/sites/www/index.php
I'm trying to get a feel for OOP with PHP/MySQL, so I attempted to
This is my code: <?php require_once '../../../jq-config.php'; // include the jqGrid Class require_once ABSPATH.php/jqGrid.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.