You are here: Where's error? Simple shoutbox code... with a few features « PHP Programming Language « IT news, forums, messages
Where's error? Simple shoutbox code... with a few features

Posted by ire.kevin on 07/29/06 02:08

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");
}
}

?>


[/code]

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация