Jump to content

Recommended Posts

Posted

Hello,

Why am I receiving this error when I try to install a donation website for my community?:

Fatal error: Call to a member function listGroups() on null in /home/luigi123/public_html/donations/index.php on line 113


Also, when I try to login, I receive this error as well.

Unable to open connection to MySQL server.
Posted

The first error is occurring because it may be depended on the MySQL connection variable. If you could open the connection to mysql successfully, it should disappear. Otherwise, if it's not depended on mysql variable then, probably you are calling a function of a class without initializing the class.

Posted

You can open a connection to MySQL by doing:

$db=mysqli_connect($host,$user,$pwd,$db);
Then use the variable to your script.

 

I need to see the code to say anything.

Posted

If you do the above a connection to MySQL database will be opened. You don't need to do anything else.

Posted

In which file do I add the code? Sorry I’m asking too many questions. I’m just trying my best to get this fix.

Posted

No problem, you can as many as you have, I would love to help you.

 

Well, can you post your code here?

Posted

Plus, I don't know how to open a connection to mysql with this code:

$db=mysqli_connect($host,$user,$pwd,$db);

Can you tell me the steps what to do so I can get this fix?

Posted

Take this example:

<?php
$host="localhost";
$user="user_example";
$pwd="password";
$db="user_database";
$con=mysqli_connect($host,$user,$pwd,$db) or die("Couldn't connect to the database: ".mysqli_error($con));
if($q=mysqli_query($con,"SELECT field1, field2 FROM example_table")){
   if(db_num_rows($q) > 0){
      while($r=mysqli_fetch_array($q)){
         echo "Field1 Value: {$r['field1']}";
         echo "<br>";
         echo "Field2 Value: {$r['field1']}";
      }
   } else {
      echo "No rows found: The table seems to be empty.";
   }
} else {
   echo "Unable to query database: ".mysqli_error($con);
}
?>
Posted

Post the code of the class as well as the script that's calling the class function. Otherwise I don't able to help you.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...