Help - Search - Members - Calendar
Full Version: Forum Posts
Zymic Webmaster Forums > Zymic Free Web Hosting > Databases & MySQL
Pixeltor
I'm creating a website with a very basic forum on it. I was wondering how a post would be stored in the database. My first guess would be a table with columns such as: "topictitle" VARCHAR(128) , "user"(who posted it) INT(id of user), and a "id" INT(11) of the post as to keep track of total posts.

but how would the actual content of the post be stored? as a VARCHAR(one billion)?, It seems like a data-comsuming method, and I have seen some posts on coding forums that are quite long. basically, Is there a limit of characters?, Is there a better way to store the content of someone's post?

thanks - Pixeltor
swordz
type = text. Otherwise, flat file storage in a dedicated folder with the names being the id.

It really is much easier to just use a phpbb3 forum, rather than write your own... But good luck!

swordz
Pixeltor
QUOTE(swordz @ May 18 2009, 08:28 PM) *
It really is much easier to just use a phpbb3 forum, rather than write your own... But good luck!

But where's the fun in that?, actually, the whole site will be based off of posts by an administrator.

ran into a weird problem when creating the registration page:

CODE

$query = mysql_query("SELECT * FROM users WHERE username=".$_POST['username']."");
if(mysql_num_rows($query))
{
echo "Username already exists";
}


I get this error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /www/uuuq.com/p/i/x/pixeleum/htdocs/registration.php on line 27

I'm pretty sure $query is a valid query blink.gif
swordz
CODE
$query = mysql_query("SELECT * FROM `users` WHERE `username`='" . mysql_real_escape_string($_POST['username']) . "'");

Try that, I'm not sure whether it will work.

Also, if there's no such user, $query === FALSE. Therefore, it's not a valid MySQL result.

swordz
Pixeltor
hey, that works!, thanks a lot.

QUOTE
Also, if there's no such user, $query === FALSE. Therefore, it's not a valid MySQL result.

btw, I would want the query to evaluate to false because that would mean that the username is not already used, right?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.