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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:21:14+00:00 2026-05-31T03:21:14+00:00

I’m having problems with mysqli_query . I have methods set up in a singleton

  • 0

I’m having problems with mysqli_query. I have methods set up in a singleton database class call connect() and querydb(), querydb takes a $query parameter which I’m sure is fine as I used the query to add data to my table in phpMyAdmin. here is my PHP method for when I attempt to add data to the table in my register.php class.

public function register() {

   $databaseinst = database:: getinstance();
   $conn =   $databaseinst->connect();

   $query = "INSERT INTO  Customer (email_address,firstname,lastname,address_line_1,address_line_2,city,postcode,country,password) VALUES ('$this->email','$this->firstname','$this->secondname','$this->address1','$this->address2','$this->city','$this->postcode','$this->country','$this->password1')";

   $numrows = $databaseinst->querydb($query);

       if ( false===$numrows ) {
    $this->errors[]= mysqli_error($conn);
    }

       if ($numrows < 1) {
            $this->errors[] = "could not process query";
        }
        if($conn == 0)
        {
        $this->errors[] = "couldnt connect";
        }
        if($conn == 1)
        {
        $this->errors[] = " connected";
        }
    }

    public function showerrors() {
        echo "<h3> ERRORS!!</h3>";
        echo "<p>" . var_dump($this->errors) . "</p>";
        foreach ($this->errors as $key => $value)
        {
            echo $value . "</br>";
        }
    }

The second method is just how I print out the errors when they occur.
Next are the methods from my database singleton class which returns an instance fine I think the issue is with the mysqli_query() method call in my querydb() method just can figure out what it is I keep getting a “could not process query” reply. Anyway here is the singleton class I used which is pretty much an edited version of one I found online.

<?php

class database {

private static $instance;
private $dbcon;
private $result;
private $numrows;


private function __construct()
{

}

  static function getinstance()
{
    if(!self::$instance)
    {
     self::$instance = new self();
    }

    return self::$instance;

 }

public function connect()
{
    $this->dbcon = mysqli_connect('localhost','********','****');
  if (!$this->dbcon)
  {
  return 0;
  }
  else
  {
  return 1;
  }

}

 public function querydb($query)
{

mysqli_select_db($this->dbcon,'theislan_testdatabase');

$this->result = mysqli_query($this->dbcon,$query);
$this->numrows = $this->result->num_rows;

   if ($this->numrows < 1)
   {
      return 0;

   }
  else 
    {
        return 1;
    }
 }
}

?>
  • 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-31T03:21:16+00:00Added an answer on May 31, 2026 at 3:21 am

    Is the user you use to connect to MySQL allowed to INSERT? In other words, is it MySQL permission that cause the problem, not PHP? Try testing with root user to establish whether that’s the case (or check permissions in PHPMyAdmin).

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a reasonable size flat file database of text documents mostly saved in
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping a

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.