Jump to content

[SOLVED] Is there any way


almightyegg

Recommended Posts

Sorry about the long reply, I haven't been able to get to a computer.

This is what I'm using it for, there is no errors echoed out but it wasn't going into the table correctly so I decided I would echo $max itself. It shows 'Resource id #20'.

<?
$max = mysql_query("SELECT MAX(id) FROM topics WHERE fid = '$f'") or die(mysql_error());
echo "$max";
$fn = is_numeric($f);
if($fn == TRUE){
$update = mysql_query("UPDATE users SET sboard = '$max' WHERE username = '{$mem['username']}'");
}else{
$update = mysql_query("UPDATE users SET $f = '$max' WHERE username = '{$mem['username']}'");
}
?>

 

If you could help me resolve this I would be extremely thankful :)

Link to comment
Share on other sites

Great that worked :D But now, there's an error elsewhere....

 

$count = $mem['$forumid'];

$count = mysql_query("SELECT * FROM topics WHERE id > '$count' AND fid = '$forumid'") or die(mysql_error());

$count = mysql_num_rows($count);

 

This code is to see how many new messages there has been since the user last looked at the board by counting the amount of row ids that are greater than the number stored in the user's row (the highest id from the last time the board was viewed). So basically, if the highest id when the board was last viewed by me was 342 and now it is 396 it would say 'Board Title 54 NEW'.

Now the problem is that the last viewed id has been stored successfully, which is 8 on my tester board and it's still 8 so it should say 'Board Title' but instead it says 'Board Title 8 NEW'. I don't understand why though. I hope somebody can shed some light onto this problem for me :)

 

Sorry if I've confused you with my babbling  :-X

Link to comment
Share on other sites

Remove the quotes around '$forum id' - the code you have gives a count = 0;

 

That's a very inefficient way of doing it. Also better strategy would be to store the DATETIME of last visit and count posts after that time.

 

$time = $lastvisited;

$res = mysql_query("SELECT COUNT(*) FROM topics WHERE dateposted > '$time' AND fid = '$forumid' ");

$count = mysql_result($res,0,0);

 

That way the query only needs to fetch a single value, not 54 rows of data.

Link to comment
Share on other sites

I had tried that previously but was unable to make it work...:(

 

and stil this way isn't working...

$count = $mem['$forumid'];

$count = mysql_query("SELECT * FROM topics WHERE id>'$count' AND fid=$forumid") or die(mysql_error());

$count = mysql_num_rows($count);

It now displays 'Unknown column 'gdis' in 'where clause'' but that doesn't make sense as I'm not naming a column as gdis (gdis being $forumid) am calling the column called fid and looking for rows which have that column filled as gdis  ??? I'm so confused :S

Link to comment
Share on other sites

Still get this: Unknown column 'gdis' in 'where clause'

I've been playing around with it, putting 's and `s around, but to no avail :(

 

$count = $mem[$forumid];
$count = mysql_query("SELECT * FROM topics WHERE `id` > '$count' AND `fid` = $forumid") or die(mysql_error());
$count = mysql_num_rows($count);

 

I can't see anything wrong. If I remove the quotes from around the $count in line 2 it makes no difference.... ???

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.