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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:47:14+00:00 2026-06-16T13:47:14+00:00

//Successful connection to $db function insert_users($db, $username, $password, $email) { echo FUNCTION CALLED; //This

  • 0
//Successful connection to $db

function insert_users($db, $username, $password, $email)
{
    echo "FUNCTION CALLED"; //This is outputted successfully

    $query = "INSERT INTO `users` (`id`, `username`, `password`, `email`) VALUES ('', ?, ?, ?)";
    $stmt = mysqli_stmt_init($db);

    if(mysqli_stmt_prepare($stmt, $query))
    {
        echo "QUERY PREPARED"; // rest of code was snipped (will put up upon request)
    } else {
        echo "QUERY DENIED"; //This is outputted successfully
    }
}


//The $user $pass and $mail are defined and then the function is called

insert_users($db, $user, $pass, $mail);

Database structure:

testdb (database)
    -> users (table)
        -> id            //Primary key, unique key
        -> username      //unique key
        -> password
        -> email

Why doens’t the query go through with it’s operation?
It echoes “Query denied” instead of “Query prepared”. The query is invalid I believe. If more information is required, ill be happy to edit this question

EDIT

I added

mysqli_stmt_error($stmt);after the echo "QUERY DENIED";
nothing happens…

EDIT 2

$server = 'localhost';
$user = 'root';
$password = '';
$databse = 'testdb';

$db = @mysqli_connect($server, $user, $password, $database) or die("Could not connect to Database server. Please inform an administrator");

That’s my database setup. Do i put the variables in quotes?

  • 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-16T13:47:15+00:00Added an answer on June 16, 2026 at 1:47 pm

    If id is an auto_increment column, you can just drop it from your insert

    INSERT INTO `users` (`username`, `password`, `email`) VALUES (?, ?, ?)
    

    You have a typo in $databse = 'testdb';. Rename it to $database.

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

Sidebar

Related Questions

I can successfully do this: App.SomeCollection = Backbone.Collection.extend({ comparator: function( collection ){ return( collection.get(
This function inserts a row into a SQL database and needs to return the
The tail-end of an OpenVPN connection (that otherwise appears successful) says (with leading timestamps
Currently all working with my jquery $.post actions, successful connections, query and json_encode return
I was successful in writing the query that lists salesmen that did sell to
After a successful start of Tomcat and a few REST calls I get this
Inside my php I have a function which creates a connection to my db,
I've got a php script as follows: function addPost(BlogPost $item, $tags) { $connection =
I'm using SQLDriverConnect function to connect to database. In connection string I can specify
My connection and fetching from the server is successful using php code below <?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.