php - mysql "between date" query works in phpmyadmin but returns nothing with PDO -


when try run php/pdo result empty, when replace variables , echo query , copy paste phpmyadmin works should.

i guess have between part in query, works if remove it.

php code:

$sql = 'select * `activity`  `activity`.`employee_id` = :id  , `activity_endtime` between :start  , :end  order :order limit 0 ,:limit';  $date_end = date('y-m-d',time()); $date_start = date('y-m-01',strtotime($date_end)); $values = array( ':id' => $_session['user_id'],  ':start' => '"'.$date_start.'"',  ':end' => '"'.$date_end.'"', ':order' => 'activity_id',  ':limit' => '10'); $q->execute($values);  while($r = $q->fetch(pdo::fetch_assoc)){  //does not here after adding between part } 

the query replacing parameters , echoing:

select * `activity`  `activity`.`employee_id` = 7  , `activity_endtime` between "2014-08-01"  , "2014-08-18"  order activity_id limit 0 ,10 

don't wrap values quotes.

change

':start' => '"'.$date_start.'"',  ':end' => '"'.$date_end.'"', 

to

':start' => $date_start,  ':end' => $date_end, 

and let me know if worked you.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -