Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 478
0 Users 18 Guests Online
Forum Index » PHP + MySQL » Problem with mysql limit query
Posted on Friday 3rd August 2007 at 02:05 PM
Diablosblizz
templates/default/images/noavatar.png's Avatar
Senior Member
Hey, I recoded my own shoutbox, and it only displays one post, but there are two posts in the database:

Code
<?php
session_start();
include("config.php");
include("bbcode12.php");
if($logged[username]) {
switch($_GET[page]) {

default:
echo "<script language=\"JavaScript\">

function refresh() {
setTimeout('dorefresh()', 30000);
}
function dorefresh() {
window.location.reload();
}
</script><body onLoad='refresh()'>";

$getcount = mysql_query("SELECT * FROM `shoutbox` ORDER BY `id` LIMIT 0, 15");
$getnum = mysql_num_rows($getcount);

if($getnum == 0) {
echo "There are no shoutbox posts.";
}
else {
$getcount = mysql_query("SELECT * FROM `shoutbox` ORDER BY `id` LIMIT 0, 15");
$t = mysql_fetch_array($getcount);
echo "<a href='members.php?user=$t[by]'>$t[by]</a>: $t[message]";
}
break;

case 'post':
if($logged[username] && $_POST[tag]) {
if(empty($_POST[message])) {
echo "You need to enter a message to submit!";
} else {
$user = $logged[username];
$msg = htmlspecialchars(stripslashes($_POST[message]));
$insert = mysql_query("INSERT INTO `shoutbox` (`by`, `message`) VALUES ('$user','$msg')");
echo "<meta http-equiv='refresh' content='0;url=box.php'>Shout Posted.";
}
}
if($logged[username] && !$_POST[tag]) {
echo "Unknown error, please go back and try again!";
}
break;
}
} else {
echo "Sorry, you must be logged in to post!";
}
?>


Shadow, you said to get rid of the limit in the shoutbox and it still did not work.

Anybody have any ideas? Thanks!
Posted on Friday 3rd August 2007 at 09:55 PM
SkillMaster
templates/default/images/noavatar.png's Avatar
Senior Member
Talk to you on msn.
Posted on Saturday 4th August 2007 at 01:05 AM
Diablosblizz
templates/default/images/noavatar.png's Avatar
Senior Member
Question also, how do I make a "swearing filter"?

:S

I tried the code below:

Code
function swear($content) {
$content = nl2br($content);
$replacement = "bobba";
$file = 'badwords.txt';
$words = file($file);

return preg_replace($words, $replacement, $content);
}


And I get:

Code
Warning: preg_replace() [function.preg-replace]: Delimiter must not be alphanumeric or backslash in C:\Program Files\xampplite\htdocs\members\bbcode12.php on line 39


I want the swear words to be in badwords.txt if possible.

Thanks!
Posted on Saturday 4th August 2007 at 02:06 AM
ShadowMage
templates/default/images/noavatar.png's Avatar
Senior Member
try str_replace instead?
Posted on Saturday 4th August 2007 at 02:56 AM
Diablosblizz
templates/default/images/noavatar.png's Avatar
Senior Member
I was able to fix this by Skill. :)

ANOTHER ANOTHER QUESTION: -.-''


Is it possible to have a PHP date go 30 minutes into the future? I want to add a timer ban to my site and I want the php to go 30 minutes into the future by using this time format:

PHP Code
1
$today = date("h:i A");


I don't want to type in the date (like Shadows tutorial). I want it to be automatic because it is a racist filter on my shoutbox and I want it to automatically ban.

Is this possible? Thanks!
Posted on Saturday 4th August 2007 at 08:41 PM
SkillMaster
templates/default/images/noavatar.png's Avatar
Senior Member
i was going to suggest
Code

$m = date("A");
$unban = $today + 0:30$m;

Dunno