While loops (Last Post)
- Momo-the-Monkey
-
Momo-the-Monkey
- Member since: Oct. 15, 2005
- Offline.
-
- Forum Stats
- Member
- Level 45
- Musician
I'm making a forum, and for some odd reason, the LAST POST part of the forum, isn't working
(forum located here)
The problem is, that the last person who posted, is displayed as "last poster" on every topic.....
http://pastebin.ca/265236 [Last Post Script]
That's the link to the LAST POST part...and here's the link to the whole page..
http://pastebin.ca/265238 [Full Script]
Can anyone fix this?
- usanamed
-
usanamed
- Member since: Jul. 12, 2006
- Offline.
-
- Forum Stats
- Member
- Level 06
- Blank Slate
Again, due to the stupid no code thing, you'll have to add "a's" when I tell you to.
HTML
A marquee
Code:
<marquee direction="up">WOW! An up marquee!!!!!</marquee>
Appears: This html is disabled on retrogade.
JavaScript
This one is to make a go back button.
Code:<[a here] href='javascript:history.go(-1)'>Go back</[a here]>
Appears:Go back
This one you can use to add your website to peoples favorites.
Code:
<[a here] href="javascript:window.external.AddFavorite( 'http://www.retrogade.com', 'http://www.CodedFX.com')" alt="Save As Fav">ADD TO FAVOURITES</[a here]>
Appears: I can't really show you how it would come out, but if it doesn't work feel free to IM me.
Easy pop-ups. This makes it so you can choose what size you want the pop-ups to be.
Code:<[a here] href="javascript:void(0)"
onclick="window.open('URL-OF-POP-UP-HERE',
'miniwin',
'toolbar=0,
location=0,
directories=0,
status=0,
menubar=0,
scrollbars=0,resizable=0
,width=470,
height=205')">TEXT-YOU-WANT-TO-DISPLAY-HERE</ [a here]>
Appears: Again, I can't show you, but if you have any comments feel free to PM me.
That's all I have time for now, but I may post some later.
- Momo-the-Monkey
-
Momo-the-Monkey
- Member since: Oct. 15, 2005
- Offline.
-
- Forum Stats
- Member
- Level 45
- Musician
Dude??!?! Do you even know what topic you're posting in?
Oh and the link to the forum is broken...it's actually at http://bs.byethost11.com/bsc/forum.php?id=1
- Jessii
-
Jessii
- Member since: Feb. 10, 2005
- Offline.
-
- Forum Stats
- Member
- Level 36
- Movie Buff
At 12/3/06 08:59 PM, Momo-the-Monkey wrote: Dude??!?! Do you even know what topic you're posting in?
I don't think he does
Oh and the link to the forum is broken...it's actually at http://bs.byethost11.com/bsc/forum.php?id=1
It still doesn't seem to work.
- Momo-the-Monkey
-
Momo-the-Monkey
- Member since: Oct. 15, 2005
- Offline.
-
- Forum Stats
- Member
- Level 45
- Musician
Ok, I don't know what i typed wrong, but here's the Copy and Paste version of the link
- Afro-Ninja
-
Afro-Ninja
- Member since: Mar. 2, 2002
- Offline.
-
- Send Private Message
- Browse All Posts (13,458)
- Block
-
- Forum Stats
- Moderator
- Level 44
- Game Developer
I'm having a look through it, but it pains me at the amount of optimization you could be doing here :(
first of all for starters- you check the $_GET['id'] to make sure it exists and that it's numeric, then you transfer it to $id and escape it with mysql_real_escape_string
That's good- but you don't need to keep referencing GET. whenever you want that id just use $id, don't keep taking it from $_GET. and you only need to escape it once, not every time you want to use it.
- Momo-the-Monkey
-
Momo-the-Monkey
- Member since: Oct. 15, 2005
- Offline.
-
- Forum Stats
- Member
- Level 45
- Musician
At 12/3/06 09:38 PM, Afro-Ninja wrote: I'm having a look through it, but it pains me at the amount of optimization you could be doing here :(
first of all for starters- you check the $_GET['id'] to make sure it exists and that it's numeric, then you transfer it to $id and escape it with mysql_real_escape_string
That's good- but you don't need to keep referencing GET. whenever you want that id just use $id, don't keep taking it from $_GET. and you only need to escape it once, not every time you want to use it.
Yes, I know i don't have to keep referring it...but If i don't...It doesn't use it for some odd reason. It like just delete's the variables everytime I start an If-statement...
Also, I know it's simple...but I can't think right now..
How do I use an if-statement to check to see if the ID exists in the database? So people can't enter a invalid ID (eg 123456789000102543851) and it just shows the blank template.
- WoogieNoogie
-
WoogieNoogie
- Member since: Jun. 26, 2005
- Offline.
-
- Forum Stats
- Member
- Level 15
- Programmer
At 12/3/06 09:51 PM, Momo-the-Monkey wrote: How do I use an if-statement to check to see if the ID exists in the database? So people can't enter a invalid ID (eg 123456789000102543851) and it just shows the blank template.
$variable = mysql_query("SELECT * FROM db WHERE ID = '$id'");
$count = mysql_num_rows($variable);
if(empty($count)) {
die("empty");
}
- Momo-the-Monkey
-
Momo-the-Monkey
- Member since: Oct. 15, 2005
- Offline.
-
- Forum Stats
- Member
- Level 45
- Musician
At 12/3/06 09:54 PM, WoogieNoogie wrote:
$variable = mysql_query("SELECT * FROM db WHERE ID = '$id'");
$count = mysql_num_rows($variable);
if(empty($count)) {
die("empty");
}
Wow....lol....Thanks!
- Afro-Ninja
-
Afro-Ninja
- Member since: Mar. 2, 2002
- Offline.
-
- Send Private Message
- Browse All Posts (13,458)
- Block
-
- Forum Stats
- Moderator
- Level 44
- Game Developer
At 12/3/06 09:54 PM, WoogieNoogie wrote:At 12/3/06 09:51 PM, Momo-the-Monkey wrote: How do I use an if-statement to check to see if the ID exists in the database? So people can't enter a invalid ID (eg 123456789000102543851) and it just shows the blank template.$variable = mysql_query("SELECT * FROM db WHERE ID = '$id'");
$count = mysql_num_rows($variable);
if(empty($count)) {
die("empty");
}
it's quicker to do a count paired with mysql_result, because then you're not actually selecting anything out
$variable =mysql_query("SELECT COUNT(id) FROM table WHERE id=$id");
if(mysql_result($variable,0,0)==0)die('this id does not exist');
- WoogieNoogie
-
WoogieNoogie
- Member since: Jun. 26, 2005
- Offline.
-
- Forum Stats
- Member
- Level 15
- Programmer
At 12/3/06 10:11 PM, Afro-Ninja wrote: it's quicker to do a count paired with mysql_result, because then you're not actually selecting anything out
I thought that at first, but you can use the method I put up along with the current query you have for displaying posts.
- Afro-Ninja
-
Afro-Ninja
- Member since: Mar. 2, 2002
- Offline.
-
- Send Private Message
- Browse All Posts (13,458)
- Block
-
- Forum Stats
- Moderator
- Level 44
- Game Developer
At 12/3/06 10:23 PM, WoogieNoogie wrote:At 12/3/06 10:11 PM, Afro-Ninja wrote: it's quicker to do a count paired with mysql_result, because then you're not actually selecting anything outI thought that at first, but you can use the method I put up along with the current query you have for displaying posts.
in that case yeah, you can just stick with your select query and don't bother with extra count
- Momo-the-Monkey
-
Momo-the-Monkey
- Member since: Oct. 15, 2005
- Offline.
-
- Forum Stats
- Member
- Level 45
- Musician
It's not working...
It keeps giving me the error that it's empty. Yet it's not.
http://bs.byethost11.com/bsc/forum.php?id=1
Click on any link....it obviously is in the Database....it's just giving me that stupid error!
I even changed empty($number) to $number != '1'. But it sitll didn't work!
- elbekko
-
elbekko
- Member since: Jul. 23, 2004
- Offline.
-
- Forum Stats
- Member
- Level 16
- Blank Slate
At 12/3/06 09:54 PM, WoogieNoogie wrote:At 12/3/06 09:51 PM, Momo-the-Monkey wrote: How do I use an if-statement to check to see if the ID exists in the database? So people can't enter a invalid ID (eg 123456789000102543851) and it just shows the blank template.$variable = mysql_query("SELECT * FROM db WHERE ID = '$id'");
$count = mysql_num_rows($variable);
if(empty($count)) {
die("empty");
}
$variable = mysql_query("SELECT * FROM db WHERE ID = '$id'");
$count = mysql_num_rows($variable);
if($count == 0) {
die("empty");
}
Should be more correct, no?
"My software never has bugs. It just develops random features. " - Unknown
[ FluxBB developer | Quickmarks 0.5.1 | Strings & Ints - my blog ]


