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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:39:04+00:00 2026-05-24T01:39:04+00:00

Different from this question , but similar in that I don’t get an error

  • 0

Different from this question, but similar in that I don’t get an error when adding information to my database.

$sql = "INSERT INTO 'nlcc_ver1'.'tUsers' ('userID', 'userName', 'userPassword', 'userHash',
'user_first_name', 'user_last_name', 'user_corps', 'is_admin', 'is_trg', 'is_sup', 'is_co')
VALUES (NULL, '" . $userName . "', '" . $hash . "', '" . $salt . "', '" . $f_name . "', '" .
$l_name . "', '" . $corps . "', '" . $admin . "', '" . $trg . "', '" . $sup . "', '" . $co . "')";
$hostname_Database = "localhost";
$database_Database = "nlcc_ver1";
$username_Database = "root";
$password_Database = "";
$mysqli = new mysqli($hostname_Database, $username_Database, $password_Database, $database_Database); 
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$result = $mysqli_query($mysqli, $sql);
echo "Query run. Inserted UserID " . mysqli_insert_id($mysqli) . "<br />";

Line breaks inserted to avoid sideways scrolling… It says on the web page that mysqli_insert_id($mysqli) is 0, and nothing is added to the table on my database. I do not see an error connecting to the database appearing, and MySQL is running on my server, and phpinfo() shows both the MySQL and MySQLI extension loaded. This is just a development machine, so don’t worry about the security (i.e. no password). I have tried googling the problem, but am not finding too much. I don’t know about object oriented PHP programming with ->, I am used to using _. Is this method still supported?

  • 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-24T01:39:05+00:00Added an answer on May 24, 2026 at 1:39 am

    You’ve mixed procedural and object-oriented MySQLi styles. This has led to you trying to use the functions like mysqli_query($mysqli) instead of the member functions like $mysqli->query(). Your $mysqli is an object, not a resource handle.

    And, you’re not performing any error checking on your query. If you were, you’d see that you have mistakenly used single quotes to delimit table and field names, not backticks.

    $sql = "INSERT INTO `nlcc_ver1`.`tUsers`
           (`userID`, `userName`, `userPassword`, `userHash`,
            `user_first_name`, `user_last_name`, `user_corps`,
            `is_admin`, `is_trg`, `is_sup`, `is_co`)
           VALUES (NULL, '" . $userName . "', '" . $hash . "', '" . $salt . "', '" .
                   $f_name . "', '" . $l_name . "', '" . $corps . "', '" . $admin .
                   "', '" . $trg . "', '" . $sup . "', '" . $co . "')";
    
    $hostname_Database = "localhost";
    $database_Database = "nlcc_ver1";
    $username_Database = "root";
    $password_Database = "";
    
    $mysqli = new mysqli($hostname_Database, $username_Database, $password_Database, $database_Database); 
    if (mysqli_connect_errno()) {
       printf("Connect failed: %s\n", mysqli_connect_error());
       exit();
    }
    
    $result = $mysqli->query($sql);
    if (!$result) {
       printf("%s\n", $mysqli->error);
       exit();
    }
    
    echo "Query run. Inserted UserID " . $mysqli->insert_id . "<br />";
    

    I strongly suggest using the manual as your reference. It’s quite clear on how to use these functions when you’re using either procedural or object-oriented style MySQLi.

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

Sidebar

Related Questions

This is similar to (but different from) this question . Here is some simple
(Similar in spirit to but different in practice from this question .) Is there
[Please note that this is a different question from the already answered How to
I know there is this question that is very similar, but I wanted to
This question is somewhat similar to How to combine two branches from two different
I asked a question an hour or two ago that is similar but this
Similar to this question , but my setup is a little different. I've written
This is a simple question from algorithms theory. The difference between them is that
I have different php output in jQuery-based tabs. This output is formed from database
I know this looks similar to other questions here but I don't think my

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.