Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8325609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:29:45+00:00 2026-06-09T00:29:45+00:00

I am trying to run an mssql stored procedure which passes in some user

  • 0

I am trying to run an mssql stored procedure which passes in some user entered data. I run the stored procedure directly and it works fine but when I try to run it using the attached code I get no error and nothing updates. I think it is something to do with the date being passed in. The date field in the database is defined as ‘datetime’. It might be something else but other stored procedures run the same way on this system are working fine.

//initiate function
    $proc = mssql_init('usp_Update_Certificate_Customer_Details', $msdb); 

    //define parameters
    $telId = $_POST['telId'];
    $certNumber = $_POST['certNumber'];
    $custTel = $_POST['main_tel'];
    $instRef = $_POST['install_ref'];
    //$commDate = $_POST['comm_date'];
    $standards = $_POST['standards'];
    $commDate = date('Y-m-d h:i:s');
    echo 'telid: '.$telId.' certNumber: '.$certNumber.' custTel: '.$custTel.' instRef: '.$instRef.' commDate: '.$commDate.' standards: '.$standards;
    mssql_bind($proc, '@Telephone_ID', $telId, SQLINT4, false, false, 10);
    mssql_bind($proc, '@Certificate_Number', $certNumber, SQLINT4, false, false, 10);
    mssql_bind($proc, '@Customer_Telephone', $custTel, SQLVARCHAR, false, false, 10);
    mssql_bind($proc, '@Installers_Reference', $instRef, SQLVARCHAR, false, false, 10);
    mssql_bind($proc, '@Commisioned_Date', $commDate, SQLDATETIME, false, false, 10);
    mssql_bind($proc, '@Installed_to_Standards', $standards, SQLVARCHAR, false, false, 10);

    //Execute Procedure 
    $result = mssql_execute($proc); 

    //Free Memory 
    mssql_free_statement($proc); 

When I run as above with the field set as ‘SQLDATETIME’ I get a php warning

    Warning: mssql_bind() expects parameter 4 to be long, string given

IF I run it with the field set as ‘SQLVARCHAR’ I get no error but no update in the database occurs

I have pasted in the stored procedure that is run below:

    SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

-- =============================================

-- Author:        Phil Yeomn

-- Create date: 19-04-2008

-- Description:   Update Customer Details

-- =============================================

ALTER PROCEDURE [dbo].[usp_Update_Certificate_Customer_Details](

@Telephone_ID INT,

@Certificate_Number Int,

@Customer_Telephone Varchar(50),

@Installers_Reference Varchar(50),

@Commisioned_Date Datetime,

@Installed_To_Standards Varchar(50)

)



AS

BEGIN

SET NOCOUNT ON;



IF @Telephone_ID <> 0 AND @Customer_Telephone IS NULL

BEGIN

      DELETE FROM ssaib.dbo.Telephone_T

      WHERE Telephone_ID = @Telephone_ID



      SET @Telephone_ID = NULL

END



IF @Telephone_ID = 0 AND @Customer_Telephone IS NOT NULL

BEGIN

INSERT INTO       ssaib.dbo.Telephone_T (Telephone_Number_VC, Last_Update_DT)

VALUES               (@Customer_Telephone, GETDATE())



SET @Telephone_ID = SCOPE_IDENTITY()

END



IF @Telephone_ID = 0

BEGIN

SET @Telephone_ID = NULL

END



UPDATE      ssaib.dbo.Certificate_Returns_T

SET         Customer_Telephone_ID = @Telephone_ID,

            Installers_Reference_VC = @Installers_Reference,

            Commisioned_Date_DT = @Commisioned_Date,

            Installed_To_Standards_VC = @Installed_To_Standards

WHERE  (Certificate_Return_ID = @Certificate_Number)





END

I have pasted the full error in below, the first line is the values that are getting passed into the stored procedure just displayed as a string to check they are all there.

telid: 61529 certNumber: 1262789 custTel: 01423 734002 instRef: /3548 commDate: 2012-05-05 00:00:00 standards: PD 6662 and DD 243
Warning: mssql_bind() expects parameter 4 to be long, string given in /home/ssaibuk/public_html/common/modules/supplier/certificates-direct.php on line 111

Warning: mssql_execute() [function.mssql-execute]: message: Procedure or function 'usp_Update_Certificate_Customer_Details' expects parameter '@Commisioned_Date', which was not supplied. (severity 16) in /home/ssaibuk/public_html/common/modules/supplier/certificates-direct.php on line 116

Warning: mssql_execute() [function.mssql-execute]: General SQL Server error: Check messages from the SQL Server (severity 16) in /home/ssaibuk/public_html/common/modules/supplier/certificates-direct.php on line 116

Warning: mssql_execute() [function.mssql-execute]: stored procedure execution failed in /home/ssaibuk/public_html/common/modules/supplier/certificates-direct.php on line 116
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:29:47+00:00Added an answer on June 9, 2026 at 12:29 am

    Believe it or not, setting the DATETIME field to VARCHAR then passing in a datetime format ‘Y-m-d H:i:s’ is the correct way to do it. You also just have to make sure the field after it (
    @Installed_To_Standards) has a capital “T” when you pass it through as it’s case sensitive.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In MySQL I'm trying to write a Stored Procedure which does the following: Run
I am trying to give a user permission to run a stored procedure at
Hi All I'm trying to run a jar a file from MSSQL stored procedure.
So I'm trying to use a stored procedure via a cursor and callproc() but
I'm trying to write a C# program, where when a user enters some data
I'm using Coldfusion8 and trying to get a simple stored procedure to run a
I am trying run a program from a qmake .pro file which modifies the
Trying to run Jison unit tests, but the command fails. How do I fix
I inherited a coldfusion8 site, which is using some search functionality. I'm trying to
for a few days I've been trying and trying to get the stored procedure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.