Zymic Forums

Webmaster resources

Zymic IRC Server

Chat in real time at irc.zymic.com - Learn More

Welcome

Welcome to the Zymic webmaster forums. Our forums are here to provide people the free ability to discuss a range of websites related topics such as design, development coding and marketing.

In order to post you will need to register for a zymic account or if you already have one simply login by using the form on the left.

left Zymic Webmaster ForumsZymic Free Web HostingDatabases & MySQL right
  Reply to this topic Start new topic
left right
Pixeltor
post May 18 2009, 11:20 PM
Post #1


Member
**

Group: Members
Posts: 59
Joined: 14-November 08
From: New Brunswick, Canada
Member No.: 68,991



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
Go to the top of the page 
 
  + Quote Post
swordz
post May 18 2009, 11:28 PM
Post #2


Outrageously Uber Ninja
*******

Group: Moderators
Posts: 1,740
Joined: 10-July 08
From: UK
Member No.: 44,994



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
Go to the top of the page 
 
  + Quote Post
Pixeltor
post May 19 2009, 08:55 PM
Post #3


Member
**

Group: Members
Posts: 59
Joined: 14-November 08
From: New Brunswick, Canada
Member No.: 68,991



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
Go to the top of the page 
 
  + Quote Post
swordz
post May 19 2009, 09:19 PM
Post #4


Outrageously Uber Ninja
*******

Group: Moderators
Posts: 1,740
Joined: 10-July 08
From: UK
Member No.: 44,994



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
Go to the top of the page 
 
  + Quote Post
Pixeltor
post May 19 2009, 09:43 PM
Post #5


Member
**

Group: Members
Posts: 59
Joined: 14-November 08
From: New Brunswick, Canada
Member No.: 68,991



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?
Go to the top of the page 
 
  + Quote Post
 Reply to this topic Start new topic
left right
0 Members:
left right
 


Lo-Fi Version Time is now: 21st November 2009 - 08:51 PM