473,378 Members | 1,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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....

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3.  
  4.  
  5. $badwordlist =
  6. array("addbadwirdsere","addbadwirdsere","addbadwirdsere","addbadwirdsere");
  7.  
  8.  
  9. mysql_connect("xxxxx","xxxx","xxxxx");
  10. mysql_select_db("xxxxxx");
  11.  
  12.  
  13. if ($_POST['submit']) {
  14. putenv('TZ=America/New_York');
  15. $time = date("F j, Y, g:i a", time());
  16.  
  17.  
  18. if (substr_count($_POST['message'],'http') < 2) {
  19. $tomanylinks = true;
  20.  
  21. }
  22.  
  23.  
  24.  
  25. foreach($badwordlist as $badword) {
  26. if (strpos($_POST['message'],$badword)) {
  27. $badwordfound = true;
  28. break;
  29. }
  30. }
  31.  
  32. if (!$tomanylinks && !$badwordfound) {
  33. $result = mysql_query("
  34. INSERT INTO shoutbox (
  35. name,
  36. message,
  37. time
  38. ) VALUES (
  39. '{$_POST['name']}',
  40. '{$_POST['message']}',
  41. '$time'
  42. )");
  43. }
  44.  
  45. if ($result) {
  46. header("Location: {$_SERVER['PHP_SELF']}");
  47. } else {
  48. die("FIRST There was an error adding to the shoutbox");
  49. }
  50.  
  51. } else {
  52. echo "<form action=\"{$_SERVER['PHP_SELF']}\"
  53. method=\"post\">";
  54. echo "  <input id=\"name\" type=\"text\" name=\"name\" />";
  55. echo "  <input type=\"submit\" name=\"submit\" value=\"Submit\"
  56. />";
  57. echo "  <textarea rows=\"2\" cols=\"35\"
  58. name=\"message\"></textarea>";
  59. echo "</form>";
  60. if ($result = mysql_query("select * from shoutbox order by id
  61. desc limit 40")) {
  62. while($r = mysql_fetch_array($result)) {
  63. ?>
  64.  
  65. <div class="weblog_comment">
  66. <div class="weblog_comment_name"><?php echo $r['name'] ?></div>
  67. <div class="weblog_comment_time"><?php echo $r['time'] ?></div>
  68. <div class="weblog_comment_message"><?php echo $r['message'] ?><br
  69. /><br /></div>
  70. </div>
  71.  
  72. <?php
  73. }
  74. } else {
  75. die("SECOND There was an error displaying the shoutbox");
  76. }
  77. }
  78.  
  79. ?>
  80.  
  81.  
  82.  
Jul 29 '06 #1
0 1338

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: delisonews | last post by:
I'm looking for a simple, filesystem-based message board. (No MySQL!) Something that I could include easily in my code: include '../inc/messageboard.php'; .... so that the board shows up at...
67
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. ...
0
by: Ming Zhu | last post by:
Hi, all, I'm new to .NET and ASP.NET. I only use .NET Framework 1.0. I'm reading the book "C# developer's guide to ASP.NET". But I find there is no place to download the code used inside this...
10
by: vwd2005eeb | last post by:
Visual Web Developer 2005 Express Edition Beta I did Build | Build Web site, where are the DLLs? I was expecting to see maybe one dll for each Web page in a directory (maybe still "bin") under...
20
by: Frank-O | last post by:
Hi , Recently I have been commited to the task of "translating" some complex statistical algorithms from Matlab to C++. The goal is to be three times as fast as matlab ( the latest) . I've...
10
by: rinawmt | last post by:
hello fren... i'm using joomla software in my website. There i put one shouth box... and for that shoutbox i'm using Ajax shoutbox, there when ever people shouth using through Guest or the member...
4
by: Svinja | last post by:
Hello, I made a shoutbox in php, the problem is that i am sending shoutbox data(name and text) with submitting forms, that way i get POSTDATA. The question is, can i send my shoutbox data to php...
20
by: David Thielen | last post by:
Hi; When we add a reference to a web app, where is that information stored? There is no project file, it's not in the web.config or solution file. ??? - thanks - dave ...
2
by: tridirk | last post by:
Hi; I am getting a Objceted Expected Error on my forum site. I can't find what is wrong? Line: Char: Error: Object expected Code:0 the site is My SMF Forum
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.