database erorr

Helpdesk for my helpdesk software

Moderator: mkoch227

craftastic
Posts: 4
Joined: Wed Jun 21, 2006 3:56 pm

Post by craftastic »

OK. I'll PM the data to you.
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Hi,

Thanks, will see if I can find out anything. By the way, which username you said was having problems? Also I assume there are no special chars in the password (just letter a-zA-Z and digits 0-9)?
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Hmm, strange, I still haven't been able to recreate your error. Please repleace your function with this one and send the debug results to me when it happens again:

Code: Select all

/***************************
Function hesk_myCategories()
***************************/
function hesk_myCategories($what='category') {

    if (!empty($_SESSION['isadmin']))
    {
    	return '1';
    }
    else
    {

        $handle = fopen("/home/craft/public_html/debug.txt", "a");
        $ses=print_r($_SESSION['categories'],true);
        fwrite($handle, "N1: $ses");
        fwrite($handle, "\n");

    	$mycat_sql='(';
        $i=1;
        foreach ($_SESSION['categories'] as $mycat)
        {

	        $ses=print_r($mycat,true);
	        fwrite($handle, "N2: $ses");
	        fwrite($handle, "\n");
	        fwrite($handle, "N3: ".gettype($mycat));
	        fwrite($handle, "\n");

            if ($i) {
            $mycat_sql.=" `$what`=$mycat ";
            } else {
            $mycat_sql.=" OR `$what`=$mycat ";
            }
        	$i=0;
        }
        $mycat_sql.=')';

        fwrite($handle, "N4: $mycat_sql");
        fwrite($handle, "\n");
        fwrite($handle, "N5: ".gettype($mycat_sql));
        fwrite($handle, "\nEND ONE CALL\n\n");
        fclose($handle);

        return $mycat_sql;
    }

} // END hesk_myCategories()
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
jfisher
Posts: 10
Joined: Fri May 26, 2006 4:01 pm

continued

Post by jfisher »

Klemen, thanks a lot for your support.
Simple logic tells me that the error we discuss here cant be due to database content. If it was, it would occur each time with login. But I tell you that the error doesn't occur since weeks on my machine (and I log into all user accounts form time to time thus using myself all kinds of user names and passwords which are stored in the database). Nothing happens on my machine, no error. But my most important partner reports errors consistently and daily but not always! I am sitting in Brazil, he is sitting in Netherlands - hard to believe that this could make a difference. In my desperation I transferred the whole system to a german dedicated server which I control.
Still no error here but still the error in Netherlands and another partner in Germany. So, no progress.
I simply cant install the original system for a trial because this is a professionally used helpdesk system and I can not demand cooperation from my partners to this extend.
Furthermore it makes little sense to let you login for replicating the error. As I told you, I dont see this error on my own machine since at least 3 weeks. So, not seeing the error doesn't prove anything.
Ofcourse I'd send you the whole database if you want. Let me know how I can do that.
Thanks for your help anyway.
J. Fisher
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Hello,

Well one thing is certain, this is one strange of an error. It has been so far reported by two people out of thousands of people who downloaded Hesk and even you see the error only sometimes?

To be honest I am not sure where to look (database seemed the most obvious in case there were any problems with categories). Seems like one of your categories is being returned as an array instead of array value. That's why it is important to log all variables and their types at the time of error, to get at least an idea of what's going on.

Have you tried the function I mentioned (my previous post)? It should only take one or a few days to log the error if it occurs that often, and it could be really helpful in finding out the reason. And your partner won't even notice any difference.

I understand your frustration, but you should also consider my position here. I can't fix an error if I can't even see it, I don't know anything about it and I can't even recreate it.

You should really give the function I posted previously a try - and when the error occurs again send the debug.txt over to me. I'll be happy to have a look and see if I can find out anything.

Regards,
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
jfisher
Posts: 10
Joined: Fri May 26, 2006 4:01 pm

agreed

Post by jfisher »

Klemen, let me clarify a point: your software is really great because it can be customized and is quite flexible.
The Login error occurs only sometimes and is a big issue only for one of my partners (and this is the most important one).
Since I saw this error several times myself, I believe what he tells me, although, as I said, I have not seen this error for some weeks and I log into the system many times daily problably more often than this partner.
I'll try to write the error into a file as proposed by you and come back as soon as I know more.
Thanks Jerome
J. Fisher
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Jerome, please don't misunderstand me; I'm not saying you our your customer is making anything up, I'm just saying I need to know more about the error if I want to help you fix it :wink:

Tell me something, do you use Hesk also for other customers? Did they report any such problems?
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
jfisher
Posts: 10
Joined: Fri May 26, 2006 4:01 pm

sure, I understand and here is more info

Post by jfisher »

I hate this kind of sometimes-happens-mistakes as much as you!
Here is what the debug.txt file shows whenever this mistake occurs:

N1: Array
(
[0] => 1
[1] => 9
[2] => 6
[3] => 10
)

N2: 1
N3: string
N2: 9
N3: string
N2: 6
N3: string
N2: 10
N3: string
N4: ( `id`=1 OR `id`=9 OR `id`=6 OR `id`=10 )
N5: string
END ONE CALL

N1: Array
(
[0] => Arra
)

N2: Arra
N3: string
N4: ( `category`=Arra )
N5: string
END ONE CALL

while the last part in caeses where everything was ok, reads like:
N1: Array
(
[0] => 1
[1] => 9
[2] => 6
[3] => 10
)

N2: 1
N3: string
N2: 9
N3: string
N2: 6
N3: string
N2: 10
N3: string
N4: ( `id`=1 OR `id`=9 OR `id`=6 OR `id`=10 )
N5: string
END ONE CALL

For me as a non programmer, it doesn't provide more insight than the error message displayed to the user on the screen. It just says the database request stucks when retrieving the user-assigned categories. It doesn't tell me anything about the reason.

No, this is the only application of hesk I have ever installed.
The above mentioned error, as I said, doesn't occur here anymore. The debug excerpt shows a failure of one of my partners. This partner says, whenever this error occurs he simply clicks on "logout" and then logs in - and everything is fine. And I see that it's true, because the next lines of debug.txt show regular database requests.
The other partner (using the same installation of hesk) says he cant login again sometimes for 20 minutes or so - this is odd and really a problem. I might be able to verify his statement tomorrow when he works (I might try to add a time recording).
I'd also give you an access to the system if you tell me which email address to use (for confidentiality).
Thanks once more.
J. Fisher
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Hi,

Well I wanted to check this because I suspected something, but nope it's not what I think. I'm not sure why your hesk_myCategories() would return "Arra", one thing to try might be that you edit your hesk_myCategories() function in inc/common.inc.php , change

Code: Select all

    if (!empty($_SESSION['isadmin']))
    {
    	return '1';
    }
to this and see if it makes any difference:

Code: Select all

    if (!empty($_SESSION['isadmin']))
    {
    	$mycat_sql= ' (`$what`) ';
        return $mycat_sql;
    }

It's a long shot, but the best I can think of now.


As for not being able to login for 20 minutes or so this is something that has to be a problem with the server, have you checked server (over)load and CPU/RAM usage when it comes to this?

Regards
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
jfisher
Posts: 10
Joined: Fri May 26, 2006 4:01 pm

sorry I dont understand

Post by jfisher »

Klemen,
I told you that I, as the administrator, do not have any such problems anymore. Hence I don't see the advantage of changing the administrator procedure.
Regarding the inability to log in: Ofcourse it's not an overload (though I wouldn't know how to check RAM-Overload or such things). He simply keeps to get the same error message again and again and therefore cant login.
I'd prefer to have the whole function myCategories() re-coded with another approach of retrieving the allowed categories for the given user. If you can do that - let me know your price - I am happy to pay for that just to get this off my desk here.
What I have done now - no idea if this works out - is: I have added single-quotation marks into your code which now looks like:
`$what`='$mycat' (instead of `$what`=$mycat as in your code).
So far, I did the change yesterday, there was no mistake anymore BUT the critical partner has not yet logged in since yesterday. So, let me wait for his login and I'll report on the outcome. Hard to imagine that this could resolve the issue though.
J. Fisher
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Hi,

... I wrote a bunch of stuff here and deleted it now because I got a new idea ...

After going through the code for about 20th time today :wink: , try this:

Open admin.php and change

Code: Select all

$_SESSION+=hesk_dbFetchAssoc($result); 
to

Code: Select all

$_SESSION=hesk_dbFetchAssoc($result); 
(all you do is remove the + sign).

Then tell your partner that (and this is important) BEFORE he tries to login again to test this simple change he should close all his browser windows.

Let me know how it goes.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Oh, by the way, changing `$what`='$mycat' won't make any difference as that is just SQL code and the problem happens before this function.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
jfisher
Posts: 10
Joined: Fri May 26, 2006 4:01 pm

thanks

Post by jfisher »

Klemen,
I have done this change but this guy will go to work in about 3 hours while here it's still in the middle of the night.
We'll see what happens.
J. Fisher
jfisher
Posts: 10
Joined: Fri May 26, 2006 4:01 pm

probably resolved

Post by jfisher »

Klemen, it seems this problem is now resolved. I registered 24 call of this function today (only the critical partner counted) and there wasn't a single error. If this confirms tomorrow, I consider this issue as resolved.

So, this is strange. It happened only once in a while.

I'll report tomorrow.
J. Fisher
jfisher
Posts: 10
Joined: Fri May 26, 2006 4:01 pm

omitting "+" solves the problem

Post by jfisher »

Klemen,
it's now for sure that your suggestion to omit "+" solved the problem. Because I wanted to know this for sure, I have used the original version this afternoon and saw a row of about 10 failed calls of the mycategories() function caused by my critical partner.
No such failure in all the time when I had removed the + as suggested by you.
So, that's for sure, the '+' made the function fail sometimes.

Thanks for all the considerations and focus.
J. Fisher
Post Reply