Hi ,

i am using mssql. I had a field with datatype datetime.

My php coding:
            $requested=date("d/m/y : H:i:s", time()); 
             i am using this query 

            insert into tbl values('$requested')

while inserting into my mssql table, i am facing the following error
Warning: mssql_query() [function.mssql-query]: message: Syntax error converting datetime from character string. (severity 16) in C:\xampp\htdocs\form.php on line 176

Warning: mssql_query() [function.mssql-query]: Query failed in C:\xampp\htdocs\form.php on line 176
unable to insert into log table

please help me out. thanks

Recommended Answers

All 3 Replies

I think if you are inserting into all the columns, you only need

insert into tbl ('$requested')

otherwise, you should specify the columns

insert into tbl ('columns') values ('$requested')

not exactly sure.

You don't require : between date and time.
i.e $requested=date("d/m/y : H:i:s", time());
should be
$requested=date("d/m/y H:i:s", time());

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.