Skip to content
Advertisement

mysqli_query return false instead of 1 row

I do not understand why mysqli_query return false, I seach a lot on internet but I have not found anything.

My code :

JavaScript

The error is :

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in … on line 55

This query always returns false but if I execute it in PHPMyAdmin I have one row returned.

Advertisement

Answer

1) MySQL reporting log locations

2) Read this answer for how to generate and read MySQL error reports.

For your code:

JavaScript

Update:

You state:

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in … on line 55

What your error means:

It means the Query did not work as expected therefore:

JavaScript

The Issues:

You are running multiple separate SQL queries in one MySQL_query query handler, which by default will not be allowed in most instances. Maybe you have set up your SQL to accept concatenated querys, but generally that’s unwise and less likely.

Alternative. You can create a PROCEDURE, FUNCTION or similar.

You are also not wrapping your column names in backticks, which is highly advisable.


Fxing your SQL:

Currently you have:

JavaScript

This can be written much more concisely as:

JavaScript

This will list all results between the first and last days of the current month. I am unclear from your code what you’re exactly trying to reach but it appears you may want the previous month’s listing, in which case you can use:

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