SQL Server keeps showing my DateTime as
in the actual database.
I'm baffeled at this. My PHP Cookbook gives me different solutions like
localtime()
, but nothing seems to work.
I use Stored Procedures for SQL Server - as you do. My Stored Procedure is below:
USE [FortissimoMedia]
GO
/****** Object: StoredProcedure [dbo].[insertHome] Script Date: 11/22/2011 23:21:37 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[insertHome] (
@PostContent TEXT,
@PostAuthor TEXT,
@DatePosted datetime,
@IP TEXT
)
AS
INSERT INTO tblHome (PostContent, PostAuthor, DatePosted, IP)
VALUES
(@PostContent, @PostAuthor, @DatePosted, @IP)
And my PHP code is below:
$con = mssql_connect(".\SQLExpress", "Username", "Password"); // hidden for obvious reasons
mssql_select_db("FortissimoMedia", $con);
$stmt = mssql_init("InsertHome", $con);
mssql_bind($stmt, '@PostContent', $_POST["PostContent"], SQLTEXT, false, false);
mssql_bind($stmt, '@PostAuthor', $PostAuthor, SQLTEXT, false, false);
mssql_bind($stmt, '@DateAdded', date("Y-m-d", time()), SQLDATETIME, false);
mssql_bind($stmt, '@IP', $_SERVER["REMOTE_ADDR"], SQLTEXT, false, false);
mssql_execute($stmt);
Maybe it's just cause I didn't get enough sleep last night or I might not be doing something right. Hope someone can advise me.
Thank you
Douglas