Uncaught mysqli_sql_exception: Table

how to proceed this, I have the table in database with name (user-groubs):

Uncaught mysqli_sql_exception: Table ‘if0_38415802_sudaniana._user_groups’ doesn’t exist in /home/vol17_1/infinityfree.com/if0_38415802/htdocs/app/core/class_db.php:95

it looks like a likely typo in your code. double check that the name of your table matches in the code and database.

Capitisation must be the same, and so must any special characters (like _)

looking at the error message, you’ve told the code to look for a table named _user_groups, but you’ve said the table is called user-groups.

5 Likes

Thanks,
The table’s name is correct, he character (-) to illustrate the table path in the database.

line 95 in class-db.php says:
$run = parent::prepare( $query);

I’m not sure what you mean by this sentence. If your table is called user-groups, you must query it as user-groups. A table user_groups is a different table. There is no automagic conversion or interpretation of table names.

And in your query, you appear to be referencing the table _user_groups, which is yet another table from user_groups and user-groups.

To stress what @dan3008 said:

The table names must be exactly the same. In programming, code either does what you want it to do or it doesn’t, there is no “basically the same”.

That code just is the final step before the query is run. It’s not helpful.

If you’re 100% sure it is correct, can you please:

  • Check the database query that’s being executed (not just where the query is executed, but the actual query text) and carefully check the tables being referenced.
  • Check the actual table names in your database. You can use phpMyAdmin for this.
8 Likes

Yes, both of you are right, there is a mistyping and I have modified it, thanks.

There is another warning:
Warning : foreach() argument must be of type array|object, bool given in /home/vol17_1/infinityfree.com/if0_38415802/htdocs/app/core/class_user.php on line 1091

Warning : Trying to access array offset on value of type bool in /home/vol17_1/infinityfree.com/if0_38415802/htdocs/app/core/class_user.php on line 1100

Warning : Undefined array key “admin” in /home/vol17_1/infinityfree.com/if0_38415802/htdocs/app/core/class_user.php on line 456

Warning : Trying to access array offset on value of type bool in /home/vol17_1/infinityfree.com/if0_38415802/htdocs/app/core/class_user.php on line 459

here is the lines:
1091 $group_data = $this->get_group_data( $group );
1100 if ( $group == $ID && $group_data[“admin_access”] ){
456 $this->group_admin = $this->data[“admin”];
459 $this->group_ID = $this->data[“group_data”][“ID”];

Like the previous time: just sharing the line on which the error occurs rarely provides enough information to solve the issue.

All error messages indicate that the variables used are of the wrong types, or are arrays where expected keys are missing.

To troubleshoot this, you should first have a look and see where these variables are being set, and what could result in the types or contents of these variables being different than expected. Then trace how they are going through the code and see where they might modified in an incorrect way. Peppering the code with var_dump(...) statements can be very helpful during debugging to make sure that the data being passed around actually looks like what you’d expect.

The downside of this troubleshooting process is that you have to do the actual work. We don’t have your full codebase, and we don’t know how it’s supposed to work. So we can’t really help you with this.


And I’m not sure whether this is your thing or not, but services like ChatGPT can be really effective at analyzing code, explaining error messages and identify possible issues. Always take the results with a grain of salt (AI chat bots can be very confidently very wrong), but it can help point you in the right direction.

4 Likes

I personally find copilot better at code myself. But fixes so many bugs, great tool

2 Likes

I personally find that Claude AI is great at code corrections, explanations, and sometimes writing code from scratch.

1 Like

Not tried Claude AI. I’ll have to look at that. I just have access to the github copilot through work, which is pretty good haha

1 Like

If you have access to GitHub Copilot, you should be able to trial the Claude AI by selecting it in the AI selector menu.

I don’t know if it is possible through your work plan though.

1 Like

Here is the last message:

SELECT * FROM _user_groups WHERE ID = ? ORDER BY ID ASC LIMIT 0, 1
Warning : foreach() argument must be of type array|object, bool given in /home/vol17_1/infinityfree.com/if0_38415802/htdocs/app/core/class_user.php on line 1091

Warning : Trying to access array offset on value of type bool in /home/vol17_1/infinityfree.com/if0_38415802/htdocs/app/core/class_user.php on line 1100

Warning : Undefined array key “admin” in /home/vol17_1/infinityfree.com/if0_38415802/htdocs/app/core/class_user.php on line 456

Warning : Trying to access array offset on value of type bool in /home/vol17_1/infinityfree.com/if0_38415802/htdocs/app/core/class_user.php on line 459
SELECT * FROM _setting_admin WHERE var = ? LIMIT 0, 1

the mentioned lines contain the following:

1091 foreach( $group_data as $_gp_k => $_gp_v ){
1100 if ( $group == $ID && $group_data[“admin_access”] ){
456 $this->group_admin = $this->data[“admin”];
459 $this->group_ID = $this->data[“group_data”][“ID”];

It seems that you may have overlooked a crucial part of my previous message:

You cannot just send us a bunch of error messages and the lines on which they occurred and be able to tell you exactly what to do. It’s your code, you have to troubleshoot it. And if you didn’t write this code, then ask these questions to the person who did. We don’t know your code, so we cannot troubleshoot this.


Looking at the errors myself, I suspect that your database query is not running unsuccessfully. If that happens, the query function will return false. That’s how you can end up with a bool somewhere in your code where you expect data from your database.

But once again, why the query is returning false, I don’t know. This sounds like a lack of proper error checking in your code, but I don’t know, because I don’t know your code.

5 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.