Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mssql_query to delete not working.

Status
Not open for further replies.

ideasworking

Programmer
Dec 2, 2001
120
CA
Hello,

About a week or so ago I upgrade PHP to version 5.2 and ever since I have had trouble with mssql_query. I'm trying to delete a record and the query fails to delete the record.

The query looks fine it's....
DELETE FROM GTG_LOG WHERE DateAndTime = '2007-1-8 1:29'

Here's my code. Any idea why this isn't working?
Thanks,
Lou

Code:
$RecDate=$_POST['OldRecordDate'];
$FirstofMonth = date("Y-m-d",mktime(0,0,0,date("m",strtotime($RecDate)) ,1,date("Y",strtotime($RecDate)))); 
$db = mssql_connect("SERVER\INSTANCE","sa","*****") or die("Unable to connect to server");
mssql_select_db("Reporting");
$QuerySQL = "DELETE FROM GTG_LOG WHERE DateAndTime = '".Date('Y-n-j G:i',strtotime($RecDate))."'";
$result = mssql_query($QuerySQL,$db) or die('Unable to delete record');
header ("Location: [URL unfurl="true"]http://intranet/logs.php?StartDate=".$FirstofMonth);[/URL]
 
I took your advice and changed the date formatting. Now the query appears as

DELETE FROM [GTG_LOG] WHERE [DateAndTime] = '2007-01-08 01:29'

However it still doesn't work. Any other ideas?

TIA,
Lou
 
Thank you,

I should have tried that myself. I typically write values to this table that do not have seconds. However when I was making the changes a couple weeks ago I wrote some SPs that included seconds. There was no way that query was going to delete the record for 2007-01-08 01:29:34.

I have made the required changes and it's working ok. Now there are still problems... but I'll start a new post for those.

Thanks again,
Lou
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top