|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38870 Die on INSERT command using MSSQL_Query
Submitted: 2006-09-18 17:36 UTC Modified: 2006-09-19 13:26 UTC
From: howardt at calhounisd dot org Assigned:
Status: Not a bug Package: MSSQL related
PHP Version: 4.4.4 OS: Windows XP, Windows Server 2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: howardt at calhounisd dot org
New email:
PHP Version: OS:


 [2006-09-18 17:36 UTC] howardt at calhounisd dot org
When running an INSERT command through MSSQL_Query, the transaction is successful (the record is inserted) but the script immediately dies ("OR die(...)" is executed).  I have followed what documentation I can find on the PHP site, but it dies every time. This does not occur on SELECT or UPDATE commands.

Reproduce code:
$MSSQL_Link = MSSQL_Connect($DistrictServer, "UserID", "password");

MSSQL_Select_DB($DistrictServerDB, $MSSQL_Link);

$Insert_Query = "INSERT INTO table(SchoolID, StateID) VALUES('$StudentNum', '$stateid')";

$Insert_Result = MSSQL_Query($Insert_Query, $MSSQL_Link) OR die("Could not insert record. " . $Insert_Query);

echo "Success";

Expected result:
"Success" should be displayed on the page.

Actual result:
"Could not insert record. INSERT INTO table(SchoolID, StateID) VALUES('123456', '987654')" is displayed instead.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-18 17:54 UTC]
Set display_errors to On, error_reporting to E_ALL and restart the webserver.
Please post the error message you get after that.
 [2006-09-18 20:40 UTC] howardt at calhounisd dot org
I set the display_errors and error_reporting as directed, restarted the service (in IIS), and I could not get an error message to display. I also tried setting track_errors=on and then referencing $php_errormsg, but still got nothing.
 [2006-09-18 20:45 UTC] phpbugs at thequod dot de
after executing the query (and remove the "or die()" 
therefor, of course).

What does it result in?
 [2006-09-19 13:24 UTC] howardt at calhounisd dot org
var_dump gives me "resource(16) of type (mssql result)", which is what I would expect.  I did a lot of research last night and this morning, and I found that the original programmer wrote internal error-handling steps embedded deep within another script, and these were causing the problem.  I have been able to work around these, and now the INSERT command works fine.  I guess the bottom line is: be VERY careful when working on somebody else's code!  Thanks for all your help!!!
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Mar 03 23:01:32 2024 UTC