php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15325 mssql_query returns early
Submitted: 2002-02-01 11:05 UTC Modified: 2003-12-19 23:44 UTC
Votes:2
Avg. Score:2.5 ± 0.5
Reproduced:0 of 1 (0.0%)
From: mike at dct-mail dot com Assigned:
Status: Not a bug Package: MSSQL related
PHP Version: 4.1.1 OS: Windows 2000 Server
Private report: No CVE-ID: None
 [2002-02-01 11:05 UTC] mike at dct-mail dot com
Running the 4.1.1 binaries from php.net:

Using mssql_query() to issue a backup statement doesn't work

$conn = msssql_connect("localhost", "sa", "") or die("bad");
$sql = "BACKUP DATABASE Northwind TO DC_Northwind";
$result = mssql_query($sql, $conn);
mssql_close($conn);

sets $result to 1 and the script prints:
MS SQL message: Cannot create worker thread. (severity 16) in Unknown on Line 0
MS SQL message: BACKUP DATABASE is terminating abnormally. (severity 16) in Unknown on Line 0

Then a dialog box reports:

The instruction at "0x100a0f9d" referenced memory at "0x00000000". The memory cannot be "written".

SQL Profiler confirms that the backup failed.

If a sleep(25) is placed after the call to mssql_query():
1) The warning messages aren't displayed
2) The backup actually succeeds
but
3) The dialog box still appears (and the script terminates).

Using the 4.0.6 binaries from the web site the backup behaves identically, BUT the dialog box does not appear and the script terminates cleanly.

The SQL Server has all service packs installed and the backup commands work without problem from the query analyzer or isql.exe

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-07 23:47 UTC] ollie at cronky dot net
Is the backup taking longer than your max script execution time (in php.ini) by any chance?
 [2002-02-08 02:54 UTC] mike at dct-mail dot com
The return from mssql_query() appears to be immediate. When the call to sleep() is present, the backup continues and completes during the sleep() and the execution timer isn't exceeded. (I verified by using a sleep(300) and did get the timer exceeded error.)
 [2002-10-28 10:53 UTC] sterling@php.net
not a php extension issue...
 [2003-12-18 13:07 UTC] sargon at tut dot by
Me too! The same error.
Php ver. 4.3.1; WinXP Pro; MSSQL 2000 SP3.
 [2003-12-19 23:44 UTC] fmk@php.net
Both php4 and php5 works fine with backups. You need to create the decice fiest with a command like this:

sp_addumpdevice 'disk', 'DC_Northwind', 'c:\backup'

This code create the backup

$con = mssql_connect("pear_mdb", "sa", "");
if ($con) {
	mssql_select_db("master", $con);

	$rs = mssql_query("BACKUP DATABASE Northwind TO DC_Northwind with format", $con);
	mssql_close($con);
}

Notice the with format, this forces the device to be overwritten on each backup.
 [2003-12-21 06:07 UTC] sargon at tut dot by
I've change PHP 4.3.1 -> 4.3.2 and all works fine with same settings.

So I think the bug is in 4.3.1
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 20:01:27 2019 UTC