|
Posted by J.O. Aho on 03/01/06 14:30
Sheldon Glickler wrote:
> "J.O. Aho" <user@example.net> wrote in message
It's really better if you do cut'n'paste the code as it is (of course for
security reasons not the login/password for your database) than modify it for
nice looking when you post, as you may manage to fix you problem when you edit
the code for posting and that way not will be able to detect the real problem.
>> Okey, then lets look at the $_SESSION['Login'], how do you set it and do
>> you really store that in a session and reuse it? How do you make the
>> mssql_connect()?
>
> Yes, I do store it and it is there. It worked for all the others.
>
> $hostname_Login = "localhost";
> $database_Login = "the database name";
> $username_Login = "the username";
> $password_Login = "the password";
> $Login = mssql_pconnect($hostname_Login, $username_Login,
> $password_Login) or die(mysql_error());
According to the code here you store the resource in $Login but in functions
you use $_SESSION['Login'], which is a reuse of a older resource which don't
have to be the same as current resource.
You should use the current one, there is always the risk that database has
closed the connection that the resource is pointing at, which makes things to
fail. You should use something like
$Login = mssql_pconnect($hostname_Login, $username_Login, $password_Login);
if(!$Login) {
echo "Theres is problem to connect with the database<br>\n";
exit;
}
die(mysql_error()) won't work for you, as you aren't using mysql, the closest
you can use would be die(mssql_get_last_message()) but the information from
mssql suxx quite a lot.
Use the $Login instead of the $_SESSION['Login'], this will most likely
require you to add the following line to your own functions
global $Login;
or add another parameter for your functions
function deleteCatalog($catalog,$sql_resource) {
$query = "DELETE FROM CatalogNames WHERE sCatalogID='" . $catalog . "'";
mssql_select_db($database_Login, $sql_resource);
$result = mssql_query($query, $sql_resource);
...
}
//Aho
[Back to original message]
|