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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP / MSSQL 1

Status
Not open for further replies.

lhatwwp

Technical User
Oct 23, 2007
79
US
Hello,

Has anyone found a method of passing a datetime parameter from PHP to MSSQL?

I need to create a new record in an MSSQL table with a DateTime data type. I have tried to use the MSSQL_Bind function and that doesn't work. I have also tried passing a tring to the SQL stored procedure and converting it to a datetime... that doesn't work either.

Any help would be greatly appreciated.

Thanks,
Lou
 
Can you post an example php script that failes, the table defintion, some test data and the error description.
 
Hello,

Here's my post from a year ago. It has an example of my code. URL:
I'm not looking for a creation date, I need to create a record for a day in the past.

If anyone can offer a solution I would greatly appreciate it.

Thanks,
Lou
 
ca you post the code of your stored proc and also can you display any error codes you get. The information you put in your bug report doesn't actualy tell anyone what went wrong, only that your proc said it failed.
Have you tried just inserting a value into a datetime column by a standard bit of php without using a SP ?
 
I created a table with a datetime data type and a stored proc that looks like:
Code:
create procedure test @stamp datetime
as
insert into dt values (@stamp)
I then created a PHP routine as
Code:
<?php
$server = mssql_connect(".");
mssql_select_db("gash",$server);
$thedate = "2005-03-03";

$stmt = mssql_init("test");
mssql_bind($stmt,'@stamp',$thedate,SQLVARCHAR,false,false,100);
mssql_execute($stmt);
?>
and the result after the insert is
2005-03-03 00:00:00.000
Whicj looks ok to me, so post your proc and let us see
 
Hello Ingresman,

Thank you so much. I have been fighting this problem on and off for over a year and never found a solution. I modified my code to match your code and YES FINALLY!!! everything works now.

Your help is greatly appreciated.

Cheers!
Lou
 
but you didnt post your proc as required on the thread. :-(

regards

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top