php - MYSQL select where timestamp data not retrieve -


i have mysql table follows;

create table if not exists `cheque_data` ( `auto_no` int(11) not null auto_increment, `job_no` int(11) not null, `client_id` text not null, `ch_no` text not null, `ch_date` date not null, `ch_bank` text not null, `ch_amount` decimal(10,2) not null, `sync` int(1) not null default '0', `timestamp` timestamp not null default current_timestamp,  primary key (`auto_no`)  ) 

when run sql command in phpmyadmin retrieve row;

select * `cheque_data` timestamp='2014-03-10 19:37:31'. 

but in php,

$sql = "select * `cheque_data` timestamp = '2014-03-10 19:37:31'"; $result_remote = mysqli_query($con,$sql) or die(mysqli_error($con)); $row_count = mysqli_num_rows($result_remote); echo $row_count; //no data 

it doesn't give data. when change timestamp other column, works.

$sql = "select * `cheque_data` auto_no = '1'"; $result_remote = mysqli_query($con,$sql) or die(mysqli_error($con)); $row_count = mysqli_num_rows($result_remote); echo $row_count; //data found 

i want know, reason issue? not working timestamp

thank you, sameera

add backticks(`) around timestamp field, reserved word or use query

$sql = "select * `cheque_data` `timestamp` = '2014-03-10 19:37:31'"; 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -