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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:31:29+00:00 2026-06-17T05:31:29+00:00

I have a problem with producing a Register using my MySQLI Code. The tables/connection

  • 0

I have a problem with producing a Register using my MySQLI Code. The tables/connection variable is matching up, and the correct variables being passed through the query is populated with expected strings, when running a query or prepare & execute when performing any type of query, I get returned with the following:

Fatal error: Call to a member function query() on a non-object in
/var/www/New/API/FormValidations.php on line 40

My code is as followed:

$Query = $STD->prepare("SELECT * FROM Users WHERE Username='$Username'");
$Query->execute();
$Number = $Query->num_rows;
if ($Number !== 0)
{
    echo "Username Already In Use";
}
else
{
$Insert_User = $STD->prepare("INSERT INTO Users ('Username', 'Password') VALUES ('$Username', '$Password)");
$Insert_User->execute();
echo "Account Created!";
}

Here is My Connection Script:

$STD = new mysqli('localhost', 'root', 'xxxxx', 'SLMS');
$AccessCon = new mysqli('localhost', 'root', 'xxxxx', 'DBAccess');

if ($AccessCon->connect_error) {
    die("Access Has Been Revoked. Please Contact Administration");
}

if ($STD->connect_error) {
    die("Standard Access Has Been Revoked. Please Contact Administration"); 
}

and my SQL Table for Users:

CREATE TABLE IF NOT EXISTS `Users` (
  `ID` int(255) NOT NULL AUTO_INCREMENT,
  `Username` varchar(255) NOT NULL,
  `Password` text NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

I have tried commenting out all my query code, and running

$Query = $STD->query("SHOW TABLES");
$Results = $STD->fetch_array(MYSQLI_ASSOC);

this still returned an error, on my $Query variable.

I have also tried modifying my code to search for something that is already present in the database:

$Query = $STD->prepare("SELECT * FROM Users WHERE Username='Test'");

and tried to enclose my $Username As followed:

$Query = $STD->prepare("SELECT * FROM Users WHERE Username='{$Username}'");

This has performed No Success. I was wondering if someone could shed some light on this situation?

Edit:

Commenting out the entire script and just running:

$Query = $STD->query("SHOW TABLES");
$test = $Query->fetch_array(MYSQLI_ASSOC);
print_r($test);

Returns a result.

UPDATE:

I have modified my code to:

$Query = $STD->prepare("SELECT * FROM Users WHERE Username=?");
                $Query->bind_param("s", $Username);
                $Query->execute();

Final Update:

Fatal error: Call to a member function bind_param() on a non-object
in /var/www/New/Register.php on line 45

This is the new Error.

The offending lines:

            $Insert_User = $STD->prepare("INSERT INTO Users ('Username', 'Password') VALUES (?, ?)");
                $Insert_User->bind_param("ss", $Username, $Password);
            $Insert_User->execute();
  • 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-17T05:31:30+00:00Added an answer on June 17, 2026 at 5:31 am

    When using prepare you have to bind the varables that hold your values.

    Example:

     $city = "Amersfoort";
    
    /* create a prepared statement */
    if ($stmt = $mysqli->prepare("SELECT District FROM City WHERE Name=?")) {
    
        /* bind parameters for markers */
        $stmt->bind_param("s", $city);
    
        /* execute query */
        $stmt->execute();
    
        /* bind result variables */
        $stmt->bind_result($district);
    
        /* fetch value */
        $stmt->fetch();
    
        printf("%s is in district %s\n", $city, $district);
    
        /* close statement */
        $stmt->close();
    }
    

    here is link to prepared statements

    Update

    this:

    $Query = $STD->prepare("SELECT * FROM Users WHERE Username=s");
    

    should be:

    $Query = $STD->prepare("SELECT * FROM Users WHERE Username=?");
    

    this:

    $Insert_User = $STD->prepare("INSERT INTO Users ('Username', 'Password') VALUES ('U', 'P)");
    

    should be:

    $Insert_User = $STD->prepare("INSERT INTO Users ('Username', 'Password') VALUES (?, ?)");
    

    this :

    $Insert_User->bind_param('U', $Username);
    $Insert_User->bind_param('P', $Password);
    

    should be this:

    $Insert_User->bind_param('ss', $Username,$Password);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem using Joda-Time for parsing and producing date and time
I have problem with my query on C, I’m using the oci8 driver. This
I have what is, to me, a confusing situation. The following code is producing
I have never encountered this sort of problem in Java before. All this code
We have some code that draws things using RVG in RMagick. We scale them
I have a SQL query that seems to be producing correct results but according
I am producing multiple forms from my php code as shown below. The problem
I have created two processes using fork(). The child process is producing and writing
I have a theory why the following code is not producing the results I
I have a problem when compiling shared libraries and executables using emacs on Windows

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.