Skip to content
Advertisement

mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, string given in while-loop

I currently have this code but it gives me the error mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, string given on line 22

The code is this:

JavaScript

I can’t seem to find the error, I am running the same code in another file and there is no issues.

Advertisement

Answer

You are overwritting $result

JavaScript

So you need to give your variables distinct names. Naming a query $result is not the best choice.


Side note.

Your inner queries are vulnerable to SQL injections. One should use prepared statements instead of concatening strings.

In example :

JavaScript

For more informations about prepared statements with mysqli, read the official documentation or the tutorials written by @YourCommonSense

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement