Jump to content

Ashoar

Members
  • Posts

    214
  • Joined

  • Last visited

    Never

Everything posted by Ashoar

  1. None, it just displayed the "0" that is normally there.
  2. Update: Neither of these helped to solve the problem. Any other ways this could be done?
  3. Thank you for the replies. I will try both of these out and see how it goes.
  4. I am working on a piece of code that will get the amount of threads made within a certain board so that they can be displayed on the main page of the forum. If i use this code without any of the board information, it works fine and will display the total amount of threads made through out the entire forum. So i believe i am doing something wrong when trying to find out what board i need to get the posts from. Here is the bit of code: $boards = mysql_query("SELECT forum_name, forum_desc, board FROM forums") or die(mysql_error()); $threads=mysql_numrows(mysql_query("SELECT post FROM post_reply WHERE board='".$name[board]."' AND parentid='0'")); $boards2 = mysql_num_rows($boards); for($count = 1; $count <= $boards2; $count++) { $name = mysql_fetch_array($boards); print "<tr class='mainrow'><td><A href='board.php?board=$name[board]'>$name[forum_name]</a><p>$name[forum_desc]</p></td><td>$threads</td><td>timeofposthere<br>lastpost here</a></td></tr>"; } The Thread variable and mysql query is the one that gets the posts. Parentid is just to make sure it is a thread and not a reply. The board variable and query is fetching all of the boards from the database along with their names, descriptions and id. I need to try and get the amount of posts in each board. The boards links are made up by their id: e.g: board.php?board=test So can someone check to see if i am doing this right? Thanks
  5. Ah fixed. Thanks guys
  6. Try changing the formats and then see how it goes: $datefrom=date("U"); //get unix timestamp EDIT: Forgot to add: $time=date("F j, Y, g:i a");
  7. Wildteen just gave me a fix to an error i was having. Any it worked fine untill i logged in as a user. Here is the code: $online = mysql_query("SELECT username FROM online") or die(mysql_error()); if(mysql_num_rows($online) > 0) { while($row = mysql_fetch_assoc($online)) { $online[] = '<A href="member_profile.php?username='.$row['username'].'">'.$row['username'].'</a>'; } echo '<tr class="mainrow"><td>Currently active: ' . implode(',', $online) . '</td></tr>'; } else { echo '<tr class="mainrow"><td>There are currently no users logged in</td></tr>'; } echo '</table>'; And here are the errors: Warning: Cannot use a scalar value as an array and Warning: implode() [function.implode]: Invalid arguments passed Another way to do this?
  8. Ah that is it. Thank you for the help.
  9. I have this small section of code. I am fetching data from a MYSQL row and wan't to display every entry in there. Normally this worlks fine but for some reason this method isn't working. Here is the bit of code: $online = mysql_query("SELECT username FROM online") or die(mysql_error()); $userrows = mysql_num_rows($online); for($count = 1; $count <= $userrows; $count++) { $name = mysql_fetch_array($online); print "<tr class='mainrow'><td>Currently active: <A href='member_profile.php?username=$name[username]'>$name[username]</a></td></tr>"; } print "</table>"; When i check, it only displays one entry and not all of them.
  10. Thank you Scott. I just realized another method of doing what i was attempting to do just before you replied. Thanks.
  11. Is it possible to refresh a database query ever x amount of seconds? For example i have this query here but i would like it to refresh and query the database again ever 60 seconds or so. $Members = mysql_query("SELECT username FROM online") or die(mysql_error());
  12. Ah that works perfectly. Silly mistake on my behalf. Thank you for all the help.
  13. That is pretty much the same as my login form after submit. Should i have a code that holds sessions and session start and include it in all pages so that we always know if the session is running?
  14. Doesn't work with either of the options
  15. Like so: $username = $_SESSION["s_username"]; But it doesn't work using either of those.
  16. After clicking login the form is checked and then i use header to send them to the main page. $_SESSION['s_logged_n'] = 'true'; $_SESSION['s_username'] = $username; $_SESSION['s_name'] = $row['Name']; header("Location: index.php"); I thought s_username would be what i would use, but it doesnt work either.
  17. Yes along with registration.
  18. It is not. I assumed it would grab the username from the table of the current session. Guess i was wrong? How else could i do this then?
  19. I am having a little problem with grabbing the name of a user from the session. I have this form that allows a member to make a post. At the top i include a variable that gets the username form the session of who is on that page. It then inserts to the database later in the script, to the author field. The problem is it is just inserting blank space to the database. When i pull the info from the database on another page it doesn't show a name. Can anyone see what i am doing wrong in this script, whether i am getting the session username wrong or something. <?php $forumid=$_GET['board']; include "config.php"; $username = $_SESSION["Username"]; print "<link rel='stylesheet' href='style.css' type='text/css'>"; print "<table class='maintables'>"; print "<tr class='headline'><td>Post a message</td></tr>"; print "<tr class='maintables'><td>"; if(isset($_POST['submit'])) { $yourpost=$_POST['yourpost']; $subject=$_POST['subject']; if(strlen($yourpost)<1) { print "You did not type in a post."; } else if(strlen($subject)<1) { print "You did not type in a subject."; } else { $thedate=date("U"); //get unix timestamp $displaytime=date("F j, Y, g:i a"); $subject=strip_tags($subject); $yourpost=strip_tags($yourpost); $insertpost=mysql_query(" INSERT INTO post_reply(board,author,title,post,showtime,realtime,lastposter) values('$forumid','$username','$subject','$yourpost','$displaytime','$thedate','$username') "); if (!$insertpost){die(mysql_error());} print "Message posted, go back to <A href='index.php'>Forum</a>."; } } else { $forumid=$_GET['board']; print "<form action='post.php?board=$forumid' method='post'>"; print "Subject:<br>"; print "<input type='text' name='subject' size='20'><br>"; print "Your message:<br>"; print "<textarea name='yourpost' rows='5' cols='40'></textarea><br>"; print "<input type='submit' name='submit' value='submit'></form>"; } print "</td></tr></table>"; ?>
  20. Try changing the second IF to an ELSE IF, in your section for updating the table information.
  21. How would i go about doing that with my current script?
  22. I already have all that. What i was wanting was to constantly update a list of every user that is currently logged in so i could display a list of logged in users. if($_SESSION['s_logged_n'] == 'true'){ That can be used quite well on a page that can only be accessed by users that are logged in. Does the same as what you said: if ($_SESSION['logged_in'])
  23. So would i use a variable containing the session though? $online = $_SESSION('username') ? And then grab the timestamp?
  24. Yes i have a small section that displays in the login that adds to the db at what time they login, and also one for when they log out. But this part here displays on every page to see if the session is still active. So what SESSION function would i use at the top of this script to get the session?
  25. I am having a bit of trouble finding out whether a user is logged in or out so that i can display a lit of the registered users online. I have this section of the code: $query = "DELETE FROM online WHERE username = '".mysql_real_escape_string($_SESSION['username'])."';"; mysql_query($query); $query = "INSERT INTO online ( username, time ) VALUES ( '".mysql_real_escape_string($_SESSION['username'])."', '".time()."' );"; mysql_query($query); mysql_close($database_connection); } What kind of Session will i need at the top to find out if they are logged in? I tried using: session_start(); if($_SESSION['s_logged_n'] == 'true'){ But that does not work. I believe i need to verify the users Username and password through the Session function. How would i do this?
×
×
  • 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.