Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff
Author Message
helsnicht
Hangin' Around


Joined: Jan 25, 2008
Posts: 44

PostPosted: Sun May 25, 2008 5:13 pm Reply with quote

I'm really at a lost as to what to of put in the subject so I just went the simple route. Having a problem with certain things from the database displaying when logged out.

Code:
    $posted = 'Submitted By: '; 

//    $posted .= get_author($aid);
    if (is_user($user)||is_admin($admin))
      $posted .= '<a href="modules.php?name=Your_Account&amp;op=userinfo&amp;username='.$aid.'">'.$userinfo['rank_abbrev'].'&nbsp;'.$userinfo['lastname'].'</a>';
    else
      $posted .= $userinfo['rank_abbrev'].'&nbsp;'.$userinfo['lastname']; //Raven 10/16/2005

This is the code inside my themes.php file. When logged in as a normal user it displays fine with no problems. But if I log out as normal user then it'll only display the space between the 'rank_abbrev' and 'lastname', its like its not getting the info from the db when your not logged in. Even with being logged in as an admin it doesn't display, only works while being logged in as a normal user. Any suggestions?

Entire code section:
Code:
function themeindex ($aid, $informant, $time, $title, $counter, $topic, $thetext, $notes, $morelink, $topicname, $topicimage, $topictext) {

    global $anonymous, $tipath, $user, $admin, $userinfo;
   $content = '';
    $thetext = '<div>'.$thetext.'</div>';
    if (!empty($notes)) {
      $notes = '<br><b>'._NOTE.'</b>&nbsp;<div>'.$notes.'</div>';
    } else {
      $notes = '';
    }
    if ($aid == $informant) {
      $content = $thetext.$notes;
    } else {
      if(!empty($informant)) {
            global $admin, $user, $userinfo;
            if (is_user($user)||is_admin($admin))
            $content = '<a href="modules.php?name=Your_Account&amp;op=userinfo&amp;username='.$informant.'" title><i>'.$userinfo['rank_abbrev'].'&nbsp;'.$userinfo['lastname'].'</i></a> ';
         else $content = $informant.' ';//Raven 10/16/2005
      } else {
          $content = $anonymous.' ';
      }
      $content .= '<i>'._WRITES.':</i>&nbsp;&nbsp;'.$thetext.$notes;
    }
    $posted = 'Submitted By: ';
//    $posted .= get_author($aid);
    if (is_user($user)||is_admin($admin))
      $posted .= '<a href="modules.php?name=Your_Account&amp;op=userinfo&amp;username='.$aid.'">'.$userinfo['rank_abbrev'].'&nbsp;'.$userinfo['lastname'].'</a>';
    else
      $posted .= $userinfo['rank_abbrev'].'&nbsp;'.$userinfo['lastname']; //Raven 10/16/2005
//     $posted .= ' '._ON.' '.$time.' ('.$counter.' '._READS.')';
       $tmpl_file = 'themes/subBlack/story_home.html';
       $thefile = implode('', file($tmpl_file));
       $thefile = addslashes($thefile);
       $thefile = '$r_file="'."$thefile".'";';
       eval($thefile);
       print $r_file;
   }
 
View user's profile Send private message Visit poster's website
evaders99
Former Moderator in Good Standing


Joined: Apr 30, 2004
Posts: 3221

PostPosted: Sun May 25, 2008 5:58 pm Reply with quote

Correct, there is no user data because $userinfo only reads the current data of the user logged in. My guess is that is not what you want. You will actually have to write your own queries to grab the data from author of that post instead

_________________
- Only registered users can see links on this board! Get registered or login! -

Need help? Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
helsnicht
PostPosted: Sun May 25, 2008 8:42 pm Reply with quote

Thanks for the reply as always evaders. Correct, I'd like for it display the same as if you was logged in or not. I'm haven't learnt myself to do queries to much extent, other then adding them to pre-existing ones already in the files.

Pissing in the wind here but, something like matching the aid in the stories tables with the username in the users tables then pull the info that way?

Code:
$result5 = $db->sql_query("SELECT * FROM " . $prefix . "_stories s JOIN " . $prefix . "_users u WHERE s.aid = u.username");

$info5 = $db->sql_fetchrow($result5);

Something like that? Or am I totally off in left field?
 
evaders99
PostPosted: Sun May 25, 2008 9:44 pm Reply with quote

Yes, code like that. You'd have to figure whether its posted by a user, as I think the stories are actually authored by the admin accounts
 
helsnicht
PostPosted: Mon May 26, 2008 9:55 am Reply with quote

Yeah I believe they are admin accounts, but my admins are named the same as their normal accounts so it should work.

Once I match the aid and username how do I retrieve info from it? There a certain way to word it? or can I just use info5[rank_abbrev]?
 
helsnicht
PostPosted: Mon Jun 09, 2008 4:20 pm Reply with quote

I've played around with this abit and haven't gotten anything to work, so I was wondering if someone could assist me? Thanks in advance.

Edit:
This code will work correct? For what I'm wanting?
Code:
$result99 = $db->sql_query("SELECT * 

FROM " . $prefix . "_users u
JOIN " . $prefix . "_authors a
WHERE u.username = a.aid");
while ( $row99 = $db->sql_fetchrow($result99) )   {
   $rank = $row99["rank_abbrev"];
   $lastname = $row99["lastname"];
}


Now for adding it, I'm not sure where I should put it as anywhere within the themeindex just gives me a parse error. As always any help is appreciated.
 
evaders99
PostPosted: Thu Jun 19, 2008 11:55 pm Reply with quote

You can't JOIN the authors table and users table like that. Assuming your username is the same as the author name, you could query based on that. This case, you will need a conditional query using the WHERE syntax

Code:


$author = get_author($aid);
$result = $db->sql_query("SELECT * FROM " . $prefix . "_users WHERE username = '" . addslashes($author) . "'");
$row = $db->sql_fetchrow($result);
$rank = $row['rank_abbrev'];
$lastname = $row['lastname'];


While this is untested code, it should give you an idea how to do this. I'm not sure if get_author is quite the correct method to use.
 
helsnicht
PostPosted: Fri Jun 20, 2008 3:14 pm Reply with quote

Thanks for the reply evaders. I'll hop back on this and see if I can't get it working with your provided code.
 
helsnicht
PostPosted: Fri Jun 20, 2008 9:19 pm Reply with quote

What I ended up doing since i couldn't get the other way to work was to add the fields into the authers tables, more work when updating a user but atleast it displays regardless if your logged in or not. Thanks for the help evaders.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©