开发者

Can mssql_query detect inserting error?

I am trying to detect inserting result.

When I tried to insert w开发者_如何学JAVAith INSERT INTO table (1,2,'t') this will result in inserting error because of the third column of my table is decimal type,but mssql_query will return true.

but when I tested with INSET INTO table (1,2,'t') this will return false,like it should.

Why the first statement returning true? and how can we check that it is an error not true!!


Correct syntax is:

insert into table_name (column_name1, column_name2, ..) 
VALUES (value_of_column1, value_of_column2, ..)

As you already know ordering part is not required, but i highly suggest you to do ordering first and then give values to it.

mysql_query return false on error and you can get error by using mysql_error function.

And keep this in your mind that you should surround values by quotations only when you are filling columns with type of varchar/char/date/datetime..

Other types like boolean, int, decimal and.. should be provided without quotations.

Hope it solve your problem ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜