Skip to content
Advertisement

Deciphering a Stack Trace Error on “Remember Me” Function

I have received my first stack trace error on a PHP beginners CRUD educational project. Since I am a newbie, I am having trouble with it. After many hours of research I believe I may have narrowed down the error to my logout method, (although this is merely my opinion). If someone can help me correct my error I would greatly appreciate it. I will attach some of my code here. Since I am not exactly sure where the error lies, I may have left something out. If that is the case I am more than happy to supply more code. Thank you in advance.

My error occurs when I click the logout button;

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error in C:xampphtdocstest_site.comclassesdb.php:51 Stack trace: #0 C:xampphtdocstest_site.comclassesdb.php(51): PDOStatement->fetchAll(5) #1 C:xampphtdocstest_site.comclassesdb.php(77): DB->query(‘DELETE FROM use…’, Array) #2 C:xampphtdocstest_site.comclassesdb.php(90): DB->action(‘DELETE’, ‘users_session’, Array) #3 C:xampphtdocstest_site.comclassesuser.php(243): DB->delete(‘users_session’, Array) #4 C:xampphtdocstest_site.comlogout.php(5): User->logout() #5 {main} thrown in C:xampphtdocstest_site.comclassesdb.php on line 51

If I comment out this code;

JavaScript

I do not get the fatal error. However, I am unable to delete the entry that was made in the database to retain the hash for the ‘remember me’ cookie.

According to the stack trace error and everything that I have tried, I keep getting this line as some sort of problem.

JavaScript

I do not know why I am having an issue here. I know this error seems huge and unmanageable but I am hoping someone here has an eye for these stack trace problems and can help me with this issue. Thanks again.

JavaScript

Advertisement

Answer

You’re doing a fetchAll after a delete query.

Try checking how many results are returned before calling fetchAll in the DB query method and see if that fixes the issue.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement