scotch33 Posted May 10, 2010 Share Posted May 10, 2010 hi, I'm trying to set an item's visibilty based on whether it has been used before. I have got to the stage where, if an item is used I write to a database and save the user's id, the artcle id and a 'lock id'. Then using a foreach I am scrolling through the articles to check whether they have been viewed, setting a session and then doing an if statement to show if the session says it's ok. That's the theory. ;-) In practice although I am getting the right callbacks from the database (a variable called lock_id shows the number of the database entry if there is an entry or '0' if there is not) I seem to be having trouble then setting the Session accordingly. However lock ID is correctly showing as a different number. Here's the code... if( isset($params['article_id']) ) { $article_id = (int)$params['article_id']; } global $gCms; $feusers = $gCms->modules['FrontEndUsers']['object']; if( $feusers ) { $uid = $feusers->LoggedInId(); $user_data = $feusers->GetUserProperties($uid); } echo "The user ID is ".$uid; echo "<br />The article ID is ".$article_id; $article_lock = mysql_query("SELECT lock_id FROM cms_module_news_lock WHERE user_id = '$uid' AND news_id = $article_id"); $article_lock_row = mysql_fetch_array($article_lock); $article_lock = (int)$article_lock_row['lock_id']; echo "<p>Lock ID:".$article_lock."</p>"; if ($article_lock > 0) { $_SESSION['locked'] = "locked"; } else { $_SESSION['locked'] = "unlocked"; } Link to comment https://forums.phpfreaks.com/topic/201279-trying-to-set-a-variable-that-wont-set/ Share on other sites More sharing options...
kenrbnsn Posted May 10, 2010 Share Posted May 10, 2010 Do you have a "session_start();" statement at the beginning of your script? Ken Link to comment https://forums.phpfreaks.com/topic/201279-trying-to-set-a-variable-that-wont-set/#findComment-1056018 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.