What is the issue with this query?
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());
What is the issue with this query? It is Running correctly in the Management Studio, but yields
Warning: mssql_query(): supplied argument is not a valid MS SQL-Link resource in
error with PHP
$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;
}
I'm sure that I'm selecting db with $db
as
INSERT INTO [dbp_mod].[dbo].[Logs] (UserID, DB_Type, DB_Name, TableName, FieldName, OldValue, NewVa开发者_StackOverflow中文版lue, SearchFields, SearchValues, Action, ActionIP, ActionTime) VALUES (1, '', '', '', '', '', '', '', '', 'Logged in ', '192.168.2.124', GetDate());
did work in both PHP and Management Studio
The error is with your DB connection, not your SQL. Inspect the db handle to see what the problem is.
What methods are available to verify a db handle is "good"?
精彩评论