php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: howardt at calhounisd dot org
New email:
PHP Version: OS:

 

 [2006-09-18 17:36 UTC] howardt at calhounisd dot org
Description:
------------
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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-18 17:54 UTC] tony2001@php.net
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
Try
var_dump($Insert_Result);
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: Fri Dec 27 01:01:28 2024 UTC