PHP warning

Undefined variable $currentUserId

/home3/jilan/public_html/protected/views/site/search.php(422)

410         } else {
411             // Handle errors
412             console.error('Request failed. Status: ' + xhr.status);
413         }
414     };
415     xhr.send(formData);
416 }
417 
418 </script>
419 <script>
420    // Function to check the follow status when the page loads
421 document.addEventListener('DOMContentLoaded', function() {
422     const currentUserId = <?= json_encode($currentUserId) ?>;
423     const profileUserId = <?= json_encode($profileUserId) ?>;
424     const followBtn = document.getElementById('follow-btn');
425     
426     // Check if the current user is following the profile user
427     if (currentUserId && profileUserId && currentUserId !== profileUserId) {
428         fetchFollowStatus(currentUserId, profileUserId, followBtn);
429     }
430 
431     // Event listener for follow/unfollow button click
432     followBtn?.addEventListener('click', function() {
433         toggleFollow(currentUserId, profileUserId, followBtn);
434     });

Stack Trace

#4
+
 /home3/jilan/public_html/protected/controllers/SiteController.php(31): CController->render("search")
26     } 
27     public function actionDisplay() {
28         $this->render('display');
29     } 
30         public function actionSearch() {
31         $this->render('search');
32     } 
33     public function actionPostInfo() {
34         $this->render('post-info');
35     }
36     public function actionIndex() {
#12
+
 /home3/jilan/public_html/index.php(22): CApplication->run()
17     defined('YII_DEBUG') or define('YII_DEBUG', true);
18 // specify how many levels of call stack should be shown in each log message
19     defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
20 
21     require_once($yii);
22     Yii::createWebApplication($config)->run();
23 }  
2026-03-10 23:58:35 Apache Yii Framework/1.1.10