Where's error? Simple shoutbox code... with a few features

This is a discussion on Where's error? Simple shoutbox code... with a few features within the PHP Language forums, part of the PHP Programming Forums category; Well I've made alot of progress (ok i lie someone made alot of progress for me) but I'm ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-29-2006
ire.kevin@gmail.com
 
Posts: n/a
Default Where's error? Simple shoutbox code... with a few features

Well I've made alot of progress (ok i lie someone made alot of progress
for me) but I'm at a hault because i get the "can't write to db" error
down in the code.

What's wrong? I can't find it....

Code:
<?php


$badwordlist =
array("addbadwirdsere","addbadwirdsere","addbadwirdsere","addbadwirdsere");


mysql_connect("xxxxx","xxxx","xxxxx");
mysql_select_db("xxxxxx");


if ($_POST['submit']) {
putenv('TZ=America/New_York');
$time = date("F j, Y, g:i a", time());


if (substr_count($_POST['message'],'http') < 2) {
$tomanylinks = true;

}



foreach($badwordlist as $badword) {
if (strpos($_POST['message'],$badword)) {
$badwordfound = true;
break;
}
}

if (!$tomanylinks && !$badwordfound) {
$result = mysql_query("
INSERT INTO shoutbox (
name,
message,
time
) VALUES (
'{$_POST['name']}',
'{$_POST['message']}',
'$time'
)");
}

if ($result) {
header("Location: {$_SERVER['PHP_SELF']}");
} else {
die("FIRST There was an error adding to the shoutbox");
}

} else {
echo "<form action=\"{$_SERVER['PHP_SELF']}\"
method=\"post\">";
echo "  <input id=\"name\" type=\"text\" name=\"name\" />";
echo "  <input type=\"submit\" name=\"submit\" value=\"Submit\"
/>";
echo "  <textarea rows=\"2\" cols=\"35\"
name=\"message\"></textarea>";
echo "</form>";
if ($result = mysql_query("select * from shoutbox order by id
desc limit 40")) {
while($r = mysql_fetch_array($result)) {
?>

<div class="weblog_comment">
<div class="weblog_comment_name"><?php echo $r['name'] ?></div>
<div class="weblog_comment_time"><?php echo $r['time'] ?></div>
<div class="weblog_comment_message"><?php echo $r['message'] ?><br
/><br /></div>
</div>

<?php
}
} else {
die("SECOND There was an error displaying the shoutbox");
}
}

?>
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:51 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0