First off, you need to arrange things differently again. Try to step through it logically. When someone updates his or message and clicks submit, the database is updated but the previous message is dispalyed, right? So you are getting the old data instead of the new. This is because your code queries for the welcome message and THEN updates. You need to query for the welcome message AFTER you update to get the latest version.
Frost also worked around the problem by changing the $olddata variable to $_POST['welcome'], but this could also be done by changing these lines (from Frost):
$olddata = "SELECT welcome FROM settings WHERE clubid = 1";
$res = mysql_query($olddata);
$olddata = mysql_fetch_assoc($res);
$olddata = $olddata['welcome'];
if (isset($_POST['welcomebtn'])) {
$query = "UPDATE settings SET welcome = '" . $_POST['welcome'] ."' WHERE clubid = 1 ";
$result = mysql_query($query) or print(mysql_error()."<br />");
$olddata = $_POST['welcome'];
if ($result) {echo ("Your welcome message has been updated" );}
else { echo ("Sorry, read the error above to find out what is wrong.");}
}
to this:
if (isset($_POST['welcomebtn'])) {
$query = "UPDATE settings SET welcome = '" . $_POST['welcome'] ."' WHERE clubid = 1 ";
$result = mysql_query($query) or print(mysql_error()."<br />");
if ($result) {echo ("Your welcome message has been updated" );}
else { echo ("Sorry, read the error above to find out what is wrong.");}
}
$olddata = "SELECT welcome FROM settings WHERE clubid = 1";
$res = mysql_query($olddata);
$olddata = mysql_fetch_assoc($res);
$olddata = $olddata['welcome'];
Which does exactly the same thing, but IMO, it seems more logical. There is really no significant difference between these variations of the code (I don't think).
Other than that, let me give you a couple tips. When posting code in this forum, surround it with "[ php ]" and "[ / php ]" (without the spaces or quotes). This will place it in a window like most people here do. It really makes it easier to read and will help more people respond to your post as I'm sure some will just skip it once they see you not posting properly.
Also, posting 4 times in a row is generally frowned upon (actually, posting more than once in a row is frowned upon). There are "edit" and "delete" buttons for a reason. If you have more to say about something, then edit your preivous post. If you decide that you need to post your code and forgot to in the last message, then just delete that last message and rewrite the whole thing with the code in it. I think you get the idea.
You might want to read some of the rest of the general guidelines in this thread http://phpbuilder.com/board/showthread.php?t=10218925 or read the FAQs here http://www.phpbuilder.com/board/faq.php?
I hope I don't seem like I'm attacking you but that is not my intention. I'm sure I don't follow all of the guidelines either, but I try to do my best. You should read that information and try to do the same.