|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-12-31 08:59 UTC] charlesk at netgaintechnology dot com
<?php
session_start();
$source = $_SERVER["HTTP_REFERER"];
session_register("source");
$connection = mssql_connect('server','UserName','password');
$sql = "select * from tbl;";
echo "$sql $connection<br>";
$sql_result = mssql_query($sql,$connection);
$num = mssql_num_rows($sql_result);
$retVal = "Records = ".$num;
if ($num > 0) {
mssql_data_seek($sql_result,0);
$row = mssql_fetch_object($sql_result);
$retVal = $row->Text;
}
mssql_free_result($sql_result);
echo $retVal;
?>
In this case the mssql_query fails with:
PHP Warning: mssql_query(): supplied argument is not a valid MS SQL-Link resource.
if I simply comment the $source = $_SERVER... it succeeds.
If I change session_register to $_SESSION["source"] = $source; it succeeds.
I am not sure how these are related.
What is even weirder is the echo "$sql $connection<br>";
They echo what is expected when it works. When it doesnt whichever was defined first is the value for both.
IE When it fails as it is written
select * from tbl_Texts; select * from tbl_Texts;
If you change
$connection = mssql_connect('server','UserName','password');
$sql = "select * from tbl;";
to
$sql = "select * from tbl;";
$connection = mssql_connect('server','UserName','password');
it echos
Resource id #3 Resource id #3
I will in the future use $_SESSION but there are alot of files to change if this wont be fixed.
Thanks
Charles Killmer
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 16:00:01 2025 UTC |
i've the same problem with linux (apache 1.3.27) + mysql. contents of nearly all variable are exchanged! with a small function i had fixed this temporarly: function dp_session_register($variable) { global ${$variable}; if(is_null(${$variable})) ${$variable}=""; return session_register($variable); } i hope, this will fixed as soon as posible. thanks. daniel priorI've had this same problem. It came from setting session variables and worked fine in older versions of PHP but started giving me the mentioned error when PHP hit version 4.3.1. <? global $my_session_variable; session_register("my_session_variable"); ?> OUTPUT HTML: "Warning: Unknown(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0" This comes from a misconception that you have to set a variable to global before it can be registered as a session. Hope this helps in any way.