unserialize() error

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
vuongduongquoc
User
Posts: 133

unserialize() error

Post by vuongduongquoc »

i enable "Track failed attempts" and it generates this error when i enter wrong password:
( ! ) Notice: unserialize(): Error at offset 172 of 1158 bytes in D:\wamp64\www\vn1erp\phpfn14.php on line 8570
My Profile field is Nvarchar (4000), i changed to Nvarchar(Max) also but it doenst solve the problem.
When i delete the field value or make it Blank it works. But when i re-enter wrong password again it re-generate same error.
How can i solve this problem?

8568 // Load profile from string
8569 function LoadProfile($Profile) {
8570 $ar = unserialize(strval($Profile));
8571 if (is_array($ar))
8572 $this->Profile = array_merge($this->Profile, $ar);
8573 }


vuongduongquoc
User
Posts: 133

Post by vuongduongquoc »

if i enter wrong password in the first login then enter correct password in second login, there's an error message on top of the web page with this information even i've logged in successfully.
Please help to remove this error message.
( ! ) Notice: unserialize(): Error at offset 277 of 1386 bytes in D:\wamp64\www\vn1erpupgrade\phpfn15.php on line 10465
Call Stack

Time Memory Function Location

1 1.9138 861744 {main}( ) ...\Contract_full_viewlist.php:0
2 2.1932 17294560 PHPMaker2019\Material\Contract_full_view_list->run( ) ...\Contract_full_viewlist.php:23
3 2.1933 17300568 PHPMaker2019\Material\UserProfile->isValidUser( ) ...\Contract_full_view_list.php:676
4 2.1934 17300568 PHPMaker2019\Material\UserProfile->loadProfileFromDatabase( ) ...\phpfn15.php:10499
5 2.1983 17328616 PHPMaker2019\Material\UserProfile->loadProfile( ) ...\phpfn15.php:10429
6 2.1983 17328616 unserialize ( ) ...\phpfn15.php:10465

and here is the code around line 10129:
10425 // Get SQL from getSql() method in <UserTable> class
10426 $sql = $UserTable->getSql($filter);
10427 $rswrk = $UserTableConn->execute($sql);
10428 if ($rswrk && !$rswrk->EOF) {
10429 $this->loadProfile($rswrk->fields(USER_PROFILE_FIELD_NAME));
10430 $rswrk->close();
10431 return TRUE;
10432 }


Webmaster
User
Posts: 9427

Post by Webmaster »

Cannot simulate. Please enable debug mode (Tools -> Advanced Settings) and try again. Login with incorrect password and show the debug sql. It should look like:

UPDATE <UserTable> SET <ProfileField> = ...

If you are a registered user, you can send your project file/database to support:
http://www.hkvstore.com/phpmaker/support.asp


vuongduongquoc
User
Posts: 133

Post by vuongduongquoc »

i'm registered user, i will send project file if you cannot find the issue in here.

( ! ) Notice: unserialize(): Error at offset 246 of 1355 bytes in D:\wamp64\www\vn1erpupgrade\phpfn15.php on line 10465
Call Stack

Time Memory Function Location

1 0.9511 512864 {main}( ) ...\Brandlistlist.php:0
2 3.2415 15742648 PHPMaker2019\Material\Brandlist_list->run( ) ...\Brandlistlist.php:23
3 3.2418 15748656 PHPMaker2019\Material\UserProfile->isValidUser( ) ...\Brandlist_list.php:672
4 3.2418 15748656 PHPMaker2019\Material\UserProfile->loadProfileFromDatabase( ) ...\phpfn15.php:10499
5 3.2506 15777344 PHPMaker2019\Material\UserProfile->loadProfile( ) ...\phpfn15.php:10429
6 3.2506 15777344 unserialize ( ) ...\phpfn15.php:10465

======================================

Debug

0.072483: Connecting... hostname: 10.0.1.251\xnkserver2; params: array ( 'ReturnDatesAsStrings' => true, 'CharacterSet' => 'UTF-8', 'Database' => 'MATERIAL', )

...

0.268692: (mssqlnative): UPDATE [dbo].[employees] SET [Profile]='a:33:{s:9:"SessionID";s:26:"h1cjfthm1s11e3oa2vov2ferq2";s:20:"LastAccessedDateTime";s:19:"2018/08/31 09:30:35";s:15:"LoginRetryCount";i:0;s:20:"LastBadLoginDateTime";s:0:"";s:23:"LastPasswordChangedDate";s:0:"";s:8:"LastName";s:14:"Dg Qc";s:9:"FirstName";s:8:"Vng";s:5:"Title";s:30:"Chief of Import Export Departm";s:15:"TitleOfCourtesy";s:3:"Mr.";s:9:"BirthDate";s:27:"1990-01-01 00:00:00.0000000";s:8:"HireDate";s:27:"2006-06-12 00:00:00.0000000";s:7:"Address";s:9:"GC";s:4:"City";s:11:"V T";s:6:"Region";N;s:10:"PostalCode";s:5:"02103";s:7:"Country";s:2:"VN";s:9:"HomePhone";s:11:"09";s:9:"Extension";s:3:"131";s:5:"Email";s:19:"test@gmail.com";s:5:"Photo";N;s:5:"Notes";N;s:9:"ReportsTo";i:0;s:9:"UserLevel";i:-1;s:8:"Username";s:5:"vuong";s:9:"Activated";s:1:"Y";s:7:"Profile";s:184:"a:5:{s:9:"SessionID";s:0:"";s:20:"LastAccessedDateTime";s:0:"";s:15:"LoginRetryCount";i:0;s:20:"LastBadLoginDateTime";s:19:"2018/08/31 09:03:31";s:23:"LastPasswordChangedDate";s:0:"";}";s:21:"NGAYBAOCAOHOPDONGFROM";s:27:"2014-04-01 00:00:00.0000000";s:14:"NGAYBAOCAOFROM";s:27:"2014-04-01 00:00:00.0000000";s:12:"NGAYBAOCAOTO";s:27:"2018-12-31 00:00:00.0000000";s:16:"FILTER_LOAI_HANG";s:47:"LOAI_HANG=''1'' or LOAI_HANG=''2'' or LOAI_HANG=''3''";s:10:"EmployeeID";i:1;s:13:"FILTER_HDGCID";s:5:"73246";s:19:"FILTER_MATERIALTYPE";s:3:"1,2";}' WHERE ([Username] = 'vuong')

0.271256: Running query: 'UPDATE [dbo].[employees] SET [Profile]=\'a:33:{s:9:"SessionID";s:26:"h1cjfthm1s11e3oa2vov2ferq2";s:20:"LastAccessedDateTime";s:19:"2018/08/31 09:30:35";s:15:"LoginRetryCount";i:0;s:20:"LastBadLoginDateTime";s:0:"";s:23:"LastPasswordChangedDate";s:0:"";s:8:"LastName";s:14:"Dg Qc";s:9:"FirstName";s:8:"Vng";s:5:"Title";s:30:"Chief";s:15:"TitleOfCourtesy";s:3:"Mr.";s:9:"BirthDate";s:27:"1978-04-03 00:00:00.0000000";s:8:"HireDate";s:27:"2006-06-12 00:00:00.0000000";s:7:"Address";s:9:"GC";s:4:"City";s:11:"V T";s:6:"Region";N;s:10:"PostalCode";s:5:"03";s:7:"Country";s:2:"VN";s:9:"HomePhone";s:11:"09";s:9:"Extension";s:3:"131";s:5:"Email";s:19:"test@gmail.com";s:5:"Photo";N;s:5:"Notes";N;s:9:"ReportsTo";i:0;s:9:"UserLevel";i:-1;s:8:"Username";s:5:"vuong";s:9:"Activated";s:1:"Y";s:7:"Profile";s:184:"a:5:{s:9:"SessionID";s:0:"";s:20:"LastAccessedDateTime";s:0:"";s:15:"LoginRetryCount";i:0;s:20:"LastBadLoginDateTime";s:19:"2018/08/31 09:03:31";s:23:"LastPasswordChangedDate";s:0:"";}";s:21:"NGAYBAOCAOHOPDONGFROM";s:27:"2014-04-01 00:00:00.0000000";s:14:"NGAYBAOCAOFROM";s:27:"2014-04-01 00:00:00.0000000";s:12:"NGAYBAOCAOTO";s:27:"2018-12-31 00:00:00.0000000";s:16:"FILTER_LOAI_HANG";s:47:"LOAI_HANG=\'\'1\'\' or LOAI_HANG=\'\'2\'\' or LOAI_HANG=\'\'3\'\'";s:10:"EmployeeID";i:1;s:13:"FILTER_HDGCID";s:5:"73246";s:19:"FILTER_MATERIALTYPE";s:3:"1,2";}\' WHERE ([Username] = \'vuong\')'; input array: false; result: NULL

i'm using MS SQL SERVER 2012.
Profile field: nvarchar 4000


Webmaster
User
Posts: 9427

Post by Webmaster »

The error message points to problem in data:
"LastName";s:14:"Dg Qc";s:9:"FirstName";s:8:"Vng"...

  1. Please try clear the profile field first (login as hard code admin and clear the profile field for this user, or use SQL Server Management Studio to clear the profile field of this record directly). Then login again to test. MAKE SURE THAT you use utf-8 project.
  2. If problem persists, clear the profile field per (1). Then open "phpfn15.php", lookup for the following lines:

// Call User Validated event
$row = $rs->fields;
var_dump($UserProfile->Profile); //*** display profile before
var_dump($row); //*** display row data
$UserProfile->assign($row);
var_dump($UserProfile->Profile); //*** display profile after

Show us the result.


vuongduongquoc
User
Posts: 133

Post by vuongduongquoc »

I added your code ad below:
// Call User Validated event
$row = $rs->fields;
$UserProfile->assign($row);
$UserProfile->delete('Password'); // Delete password
$valid = $this->User_Validated($row) !== FALSE; // For backward compatibility
}
and the errors when input wrong password:

( ! ) Notice: unserialize(): Error at offset 172 of 1088 bytes in D:\wamp64\www\vn1erpupgrade\phpfn15.php on line 10450
Call Stack

Time Memory Function Location

1 0.0004 389520 {main}( ) ...\login.php:0
2 0.1867 13554408 PHPMaker2019\Material\login->run( ) ...\login.php:23
3 0.2308 15260024 PHPMaker2019\Material\UserProfile->exceedLoginRetry( ) ...\login.php:495
4 0.2309 15260024 PHPMaker2019\Material\UserProfile->loadProfileFromDatabase( ) ...\phpfn15.php:10484
5 0.2356 15288128 PHPMaker2019\Material\UserProfile->loadProfile( ) ...\phpfn15.php:10414
6 0.2356 15288128 unserialize ( ) ...\phpfn15.php:10450

( ! ) Notice: unserialize(): Error at offset 172 of 1088 bytes in D:\wamp64\www\vn1erpupgrade\phpfn15.php on line 10450
Call Stack

Time Memory Function Location

1 0.0004 389520 {main}( ) ...\login.php:0
2 0.1867 13554408 PHPMaker2019\Material\login->run( ) ...\login.php:23
3 0.4983 15263168 PHPMaker2019\Material\AdvancedSecurity->validateUser( ) ...\login.php:525
4 0.5032 15289872 PHPMaker2019\Material\UserProfile->loadProfileFromDatabase( ) ...\phpfn15.php:6444
5 0.5085 15316448 PHPMaker2019\Material\UserProfile->loadProfile( ) ...\phpfn15.php:10414
6 0.5086 15316448 unserialize ( ) ...\phpfn15.php:10450

=======================

Debug

0.001980: Connecting... hostname: 10.0.1.251\xnkserver2; params: array ( 'ReturnDatesAsStrings' => true, 'CharacterSet' => 'UTF-8', 'Database' => 'MATERIAL', )

0.004950: (mssqlnative): SET DATEFORMAT ymd

0.006630: Running query: 'SET DATEFORMAT ymd'; input array: false; result: NULL

...

0.434231: (mssqlnative): UPDATE [dbo].[employees] SET [Profile]='a:3:{s:15:"LoginRetryCount";i:1;s:20:"LastBadLoginDateTime";s:19:"2018/08/31 13:00:03";s:23:"LastPasswordChangedDate";s:0:"";}' WHERE ([Username] = 'vuong')

0.436194: Running query: 'UPDATE [dbo].[employees] SET [Profile]=\'a:3:{s:15:"LoginRetryCount";i:1;s:20:"LastBadLoginDateTime";s:19:"2018/08/31 13:00:03";s:23:"LastPasswordChangedDate";s:0:"";}\' WHERE ([Username] = \'vuong\')'; input array: false; result: NULL

=============================debug when enter correct password===================
Debug

0.002366: Connecting... hostname: 10.0.1.251\xnkserver2; params: array ( 'ReturnDatesAsStrings' => true, 'CharacterSet' => 'UTF-8', 'Database' => 'MATERIAL', )

...

0.199358: (mssqlnative): UPDATE [dbo].[employees] SET [Profile]='a:31:{s:15:"LoginRetryCount";i:0;s:20:"LastBadLoginDateTime";s:19:"2018/08/31 13:00:03";s:23:"LastPasswordChangedDate";s:10:"2018/08/31";s:8:"LastName";s:14:"Dương Quốc";s:9:"FirstName";s:8:"Vượng";s:5:"Title";s:30:"Chief of Import Export Departm";s:15:"TitleOfCourtesy";s:3:"Mr.";s:9:"BirthDate";N;s:8:"HireDate";N;s:7:"Address";N;s:4:"City";N;s:6:"Region";N;s:10:"PostalCode";N;s:7:"Country";N;s:9:"HomePhone";N;s:9:"Extension";N;s:5:"Email";s:19:"vuong@seshin.com.vn";s:5:"Photo";N;s:5:"Notes";N;s:9:"ReportsTo";i:0;s:9:"UserLevel";i:-1;s:8:"Username";s:5:"vuong";s:9:"Activated";s:1:"Y";s:7:"Profile";s:126:"a:3:{s:15:"LoginRetryCount";i:1;s:20:"LastBadLoginDateTime";s:19:"2018/08/31 13:00:03";s:23:"LastPasswordChangedDate";s:0:"";}";s:21:"NGAYBAOCAOHOPDONGFROM";s:27:"2014-04-01 00:00:00.0000000";s:14:"NGAYBAOCAOFROM";s:27:"2014-04-01 00:00:00.0000000";s:12:"NGAYBAOCAOTO";s:27:"2018-12-31 00:00:00.0000000";s:16:"FILTER_LOAI_HANG";s:47:"LOAI_HANG=''1'' or LOAI_HANG=''2'' or LOAI_HANG=''3''";s:10:"EmployeeID";i:1;s:13:"FILTER_HDGCID";s:5:"73246";s:19:"FILTER_MATERIALTYPE";s:3:"1,2";}' WHERE ([Username] = 'vuong')

0.202739: Running query: 'UPDATE [dbo].[employees] SET [Profile]=\'a:31:{s:15:"LoginRetryCount";i:0;s:20:"LastBadLoginDateTime";s:19:"2018/08/31 13:00:03";s:23:"LastPasswordChangedDate";s:10:"2018/08/31";s:8:"LastName";s:14:"Dương Quốc";s:9:"FirstName";s:8:"Vượng";s:5:"Title";s:30:"Chief of Import Export Departm";s:15:"TitleOfCourtesy";s:3:"Mr.";s:9:"BirthDate";N;s:8:"HireDate";N;s:7:"Address";N;s:4:"City";N;s:6:"Region";N;s:10:"PostalCode";N;s:7:"Country";N;s:9:"HomePhone";N;s:9:"Extension";N;s:5:"Email";s:19:"vuong@seshin.com.vn";s:5:"Photo";N;s:5:"Notes";N;s:9:"ReportsTo";i:0;s:9:"UserLevel";i:-1;s:8:"Username";s:5:"vuong";s:9:"Activated";s:1:"Y";s:7:"Profile";s:126:"a:3:{s:15:"LoginRetryCount";i:1;s:20:"LastBadLoginDateTime";s:19:"2018/08/31 13:00:03";s:23:"LastPasswordChangedDate";s:0:"";}";s:21:"NGAYBAOCAOHOPDONGFROM";s:27:"2014-04-01 00:00:00.0000000";s:14:"NGAYBAOCAOFROM";s:27:"2014-04-01 00:00:00.0000000";s:12:"NGAYBAOCAOTO";s:27:"2018-12-31 00:00:00.0000000";s:16:"FILTER_LOAI_HANG";s:47:"LOAI_HANG=\'\'1\'\' or LOAI_HANG=\'\'2\'\' or LOAI_HANG=\'\'3\'\'";s:10:"EmployeeID";i:1;s:13:"FILTER_HDGCID";s:5:"73246";s:19:"FILTER_MATERIALTYPE";s:3:"1,2";}\' WHERE ([Username] = \'vuong\')'; input array: false; result: NULL

...

=========================Profile when enter wrong password====================

a:3:{s:15:"LoginRetryCount";i:1;s:20:"LastBadLoginDateTime";s:19:"2018/08/31 13:00:03";s:23:"LastPasswordChangedDate";s:0:"";}
=========================Profile when enter correct password==========================

a:31:{s:15:"LoginRetryCount";i:0;s:20:"LastBadLoginDateTime";s:19:"2018/08/31 13:00:03";s:23:"LastPasswordChangedDate";s:10:"2018/08/31";s:8:"LastName";s:14:"Duong Qu?c";s:9:"FirstName";s:8:"Vu?ng";s:5:"Title";s:30:"Chief of Import Export Departm";s:15:"TitleOfCourtesy";s:3:"Mr.";s:9:"BirthDate";N;s:8:"HireDate";N;s:7:"Address";N;s:4:"City";N;s:6:"Region";N;s:10:"PostalCode";N;s:7:"Country";N;s:9:"HomePhone";N;s:9:"Extension";N;s:5:"Email";s:19:"vuong@seshin.com.vn";s:5:"Photo";N;s:5:"Notes";N;s:9:"ReportsTo";i:0;s:9:"UserLevel";i:-1;s:8:"Username";s:5:"vuong";s:9:"Activated";s:1:"Y";s:7:"Profile";s:126:"a:3:{s:15:"LoginRetryCount";i:1;s:20:"LastBadLoginDateTime";s:19:"2018/08/31 13:00:03";s:23:"LastPasswordChangedDate";s:0:"";}";s:21:"NGAYBAOCAOHOPDONGFROM";s:27:"2014-04-01 00:00:00.0000000";s:14:"NGAYBAOCAOFROM";s:27:"2014-04-01 00:00:00.0000000";s:12:"NGAYBAOCAOTO";s:27:"2018-12-31 00:00:00.0000000";s:16:"FILTER_LOAI_HANG";s:47:"LOAI_HANG='1' or LOAI_HANG='2' or LOAI_HANG='3'";s:10:"EmployeeID";i:1;s:13:"FILTER_HDGCID";s:5:"73246";s:19:"FILTER_MATERIALTYPE";s:3:"1,2";}


Webmaster
User
Posts: 9427

Post by Webmaster »

Possibly due to not saving string with N for MSSQL. If you are a registered user, just click Tools -> Update Template.


vuongduongquoc
User
Posts: 133

Post by vuongduongquoc »

I updated today's template and error was fixed.
Cannot re-generate this error again.

Thanks


Post Reply