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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:22:12+00:00 2026-06-17T23:22:12+00:00

I am trying to insert into a table with Procedural Mysqli. It is not

  • 0

I am trying to insert into a table with Procedural Mysqli. It is not posting any errors nor is it posting the information to the database. Here is my code:

$query = "INSERT INTO Accounts (FirstName, LastName, Username, Password, Access) VALUES ({$_POST['FirstNameTbx']}, {$_POST['LastNameTbx']}, {$_POST['UsernameTbx']}, {$_POST['PasswordTbx']}, {$_POST['AccessDDL']})";
        mysqli_query($link, $query);
        mysqli_close($link);
        $Error .= "$query";

Update:
I changed to prepared statement, now I am getting:

Warning: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of elements in type definition string doesn’t match number of bind variables in /home/bryantrx/public_html/ec/add_user.php on line 19

There are only 5 variables that need to be bound, and the UserID auto increments, so it doesn’t need to be bound or referenced in the statement..

if ($stmt = $link->prepare("INSERT INTO Accounts (FirstName, LastName, Username, Password, Access) VALUES (?, ?, ?, ?, ?)")){
            $stmt->bind_param($_POST['FirstNameTbx'], $_POST['LastNameTbx'], $_POST['UsernameTbx'], $_POST['PasswordTbx'], $_POST['AccessDDL']);
            $stmt->execute();   
            $Error .= "success";
            $stmt->close();
        } else {
            echo $link->error;
        }
  • 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-17T23:22:13+00:00Added an answer on June 17, 2026 at 11:22 pm

    To get an error message you need to call mysqli_error:

    $error = mysqli_error($link);
    

    You would also make life easier (and more secure) for yourself if you built your queries using prepare and parameters:

    $query = "INSERT INTO Accounts (FirstName, LastName, Username, Password, Access) 
                VALUES ( ?, ?, ?, ?, ?)";
    
    if ($stmt = mysqli_stmt_prepare($link, $query)) {
    
        mysqli_stmt_bind_param($stmt, "sssss", 
                    $_POST['FirstNameTbx'], 
                    $_POST['LastNameTbx'], 
                    $_POST['UsernameTbx'], 
                    $_POST['PasswordTbx'], 
                    $_POST['AccessDDL']);
    
        if (!mysqli_stmt_execute($stmt)) {
            $error = mysqli_stmt_error($stmt);
        }
    
        mysqli_stmt_close($stmt);
    
    } else {
        $error = mysqli_error($link);
    }
    
    mysqli_close($link);
    

    UPDATE – ok, you’ve swapped to OO which is fine. When using bind_param the first parameter describes the data you are binding. In this case if it is five strings, you would put 5 “s” like so:

    $stmt->bind_param("sssss", 
               $_POST['FirstNameTbx'], 
               $_POST['LastNameTbx'], 
               $_POST['UsernameTbx'], 
               $_POST['PasswordTbx'], 
               $_POST['AccessDDL']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to accomplish what is described here: http://sqldev.wordpress.com/2008/05/06/insert-into-temporary-table-from-stored-procedure/ The article says (with support
I am trying to insert into my database table using the database helper class.
I'am trying to insert record into db2 table and getting a result with response.write.
I am trying to insert date into a table but the date and format
I am trying to insert data into a table in sorted order, for later
I am trying to insert a record into a table using Linq but get
I am trying to insert certain values into the table using SQL server 2005.
I'm trying to do an Insert operation using iBatis. INSERT INTO SCHEMA.TABLE (FIELD1, FIELD2,
I am trying to insert some text data into a table in SQL Server
I am just trying to insert my xml data into a table through calling

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.