Here is my code:
**The result of the query directly on Mysql (I’m using Navicat) is working fine. **
**but using this code above it gives ‘0’ **
$result_rap=mysqli_query($conn , "SELECT count(*) AS total FROM articles
WHERE STR_TO_DATE(date_rapport, '%d-%m-%Y') >= STR_TO_DATE( '$day_rapport1' , '%d-%m-%Y')
AND STR_TO_DATE(date_rapport, '%d-%m-%Y') <= STR_TO_DATE( '$day_rapport2' , '%d-%m-%Y')
AND (articles.theme = 'Analphabétisme'
OR articles.theme = 'Alphabétisation'
OR articles.theme = 'Analphabète')" );
while ($data_rap=mysqli_fetch_assoc($result_rap)) {
echo "Total pages ".$data_rap['total'];
}
Hi @Dormilich
They are dates in string format !
eg : $day_rapport1 = ‘08-11-2018’
-here is the “echo” of the sql query :
SELECT count(*) AS total FROM articles WHERE STR_TO_DATE(date_rapport, '%d-%m-%Y') >= STR_TO_DATE( '08-11-2018' , '%d-%m-%Y') AND STR_TO_DATE(date_rapport, '%d-%m-%Y') <= STR_TO_DATE( '08-11-2018' , '%d-%m-%Y') AND (articles.theme = 'Analphabétisme' OR articles.theme = 'Alphabétisation' OR articles.theme = 'Analphabète')
Encoding issue with the way the search strings are typed into the PHP code, perhaps? Would they not be better encoded in some way and stored in a separate table, or do they not repeat sufficiently for that?
yes @droopsnoot , Issue is fixed , finally i discovered that the special characters like “é” are blocking the query from being executed on the server, i used this encoding types >>
$con->query('SET NAMES utf8');
$con->query('SET CHARACTER utf8');