Jump to content

trying to set a variable that won't set...


scotch33

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.