# Variable reuse problem

- Thread: https://externals.io/message/25896
- Original archive: https://news-web.php.net/php.internals/25896
- Started by Frank M. Kromann on 2006-09-29T17:45:48+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #25896 — Frank M. Kromann — 2006-09-29T17:45:48+00:00

URL: https://externals.io/message/25896#25896

Hello Everyone,

I have a small problem with the mssql extension and resources (Tested with
PHP 5.2).

If I use the same variable to store the resource for a result the second
result is not always correct!

// Example 1 does not work
$rs = mssql_query("select 1");
$rs = mssql_query("select 3 select 2 select 1");

// Example 2 works fine
$rs1 = mssql_query("select 1");
$rs2 = mssql_query("select 3 select 2 select 1");

// Example 3 works fine
$rs = mssql_query("select 1");
mssql_free_result($rs);
$rs = mssql_query("select 3 select 2 select 1");

// Example 4 works fine
$rs = mssql_query("select 1");
unset($rs);
$rs = mssql_query("select 3 select 2 select 1");

The registered destructor is called in all four situations.

So why is there a difference between asigning a new resource value to a
variable with and without the unset()?

- Frank
