INSERT INTO [dbp_mod].[dbo].[Logs] (UserID, DB_Type, DB_Name, TableName, FieldName, OldValue, NewValue, SearchFields, SearchValues, Action, ActionIP, ActionTime) VALUES (1, 'DBF', 'E:\dbf\dbtest.dbf', 'E:\dbf\dbtest.dbf', 'f3', '8', '10', 'f1', '1', 'Edited', '192.168.2.124', GetDate());
此查询有什么问题?它在Management Studio中正确运行,但产生
PHP的 Warning: mssql_query(): supplied argument is not a valid MS SQL-Link resource in
错误
$query = "INSERT INTO [dbo].[Logs] (UserID, DB_Type, DB_Name, TableName, FieldName, OldValue, NewValue, SearchFields, SearchValues, Action, ActionIP, ActionTime)
VALUES ($data[UserID], '$data[DB_Type]', '$data[DB_Name]', '$data[TableName]', '$data[FieldName]', '$data[OldValue]', '$data[NewValue]', '$data[SearchFields]', '$data[SearchValues]', '$data[Action]', '$data[ActionIP]', GetDate()); ";
echo "<br>$query";
if(!mssql_query($query, $db)){
$successFlag = FALSE;
} else {
$successFlag = TRUE;
}
我确定我选择的数据库$db
为
INSERT INTO [dbp_mod].[dbo].[Logs] (UserID, DB_Type, DB_Name, TableName, FieldName, OldValue, NewValue, SearchFields, SearchValues, Action, ActionIP, ActionTime) VALUES (1, '', '', '', '', '', '', '', '', 'Logged in ', '192.168.2.124', GetDate());
在PHP和Management Studio中都有效
答案 0 :(得分:0)
错误在于您的数据库连接,而不是您的SQL。检查db句柄以查看问题所在。
可用于验证数据库句柄的方法是“好”吗?