Forums
This topic is locked
MySql and forums.
22 Apr 2007 00:03:49 Xeon 133 posted:
I have tryed to set up forums on my website, but the problem is I dont know how to currently code a MySql for forums. Im aslo wanting to make me a little admin panel for the whole site in which im going to need usernames and passwords, would that be done with MySQL?Edited by - Xeon133 on 22 Apr 2007 00:04:20
Replies
Replied 23 Apr 2007 14:22:28
23 Apr 2007 14:22:28 Alan C replied:
HI.
do a search on google for something like php free forum and you will get loads, it is then a matter of installing a few and deciding which features you like, alternatively, find a forum that you use, like this one, then look at the bottom of the page for the link to where the forum code came from.
You may be able to hack the code to use the same login too
do a search on google for something like php free forum and you will get loads, it is then a matter of installing a few and deciding which features you like, alternatively, find a forum that you use, like this one, then look at the bottom of the page for the link to where the forum code came from.
You may be able to hack the code to use the same login too
Replied 23 Apr 2007 15:36:11
23 Apr 2007 15:36:11 Xeon 133 replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
HI.
do a search on google for something like php free forum and you will get loads, it is then a matter of installing a few and deciding which features you like, alternatively, find a forum that you use, like this one, then look at the bottom of the page for the link to where the forum code came from.
You may be able to hack the code to use the same login too
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Im useing phpBB, but I dont know how to code the database to run the forums.
HI.
do a search on google for something like php free forum and you will get loads, it is then a matter of installing a few and deciding which features you like, alternatively, find a forum that you use, like this one, then look at the bottom of the page for the link to where the forum code came from.
You may be able to hack the code to use the same login too
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Im useing phpBB, but I dont know how to code the database to run the forums.
Replied 30 Apr 2007 06:03:26
30 Apr 2007 06:03:26 Alan C replied:
I have been away - hence the delay in responding.
www.phpbb.com/support/documentation/3.0/quickstart/quick_installation.php
is the documentation for phpbb, what you will need to do depends on your hosting package, I only do mysql, so i would open my control panel (cpanel) the go to the mysql section, here I would add a new database like phpbb which would end up getting a name like username_phpbb, then add a new user and finally assign that database to the user I added. Why? because it keeps things secure, different database and user combination for different jobs.
There is also the password for that user.
Now add those details to phpbb and try it, sorry if this sounds vague, but you would need to alter it slightly depending on what your hosting package demands. There are many that have an installer that does the database for you. Where is asks for host, try localhost first.
All you should have to tell phpbb is explained in the link above, if that's not clear please post details and I'll try to help
Hope that helps
www.phpbb.com/support/documentation/3.0/quickstart/quick_installation.php
is the documentation for phpbb, what you will need to do depends on your hosting package, I only do mysql, so i would open my control panel (cpanel) the go to the mysql section, here I would add a new database like phpbb which would end up getting a name like username_phpbb, then add a new user and finally assign that database to the user I added. Why? because it keeps things secure, different database and user combination for different jobs.
There is also the password for that user.
Now add those details to phpbb and try it, sorry if this sounds vague, but you would need to alter it slightly depending on what your hosting package demands. There are many that have an installer that does the database for you. Where is asks for host, try localhost first.
All you should have to tell phpbb is explained in the link above, if that's not clear please post details and I'll try to help
Hope that helps
Replied 30 Apr 2007 14:47:43
30 Apr 2007 14:47:43 Xeon 133 replied:
Well i didnt know the password of my database, and so i set one, and the installation went great. Thanks
I do have another question, but its about MySql tables, and values, How high of a number can you have, or is there some kinda of wildcard?
Edited by - Xeon133 on 30 Apr 2007 14:51:05
I do have another question, but its about MySql tables, and values, How high of a number can you have, or is there some kinda of wildcard?
Edited by - Xeon133 on 30 Apr 2007 14:51:05
Replied 01 May 2007 17:15:22
01 May 2007 17:15:22 Alan C replied:
great to hear it worked <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
your mysql question - depends on the type of data that you specify, the full overview of data types is here
dev.mysql.com/doc/refman/5.0/en/data-types.html
when you are setting up tables it's worth thinking about how much space they are going to take up. For instance with integers you can have a TINYINT which will hold integers in the range -128 to +127 or 0-255 if they are unsigned. There are various other integer formats that will take numbers that are huge. However, there is a price to pay because they take up more storage space - so for instance if you use a byte too many and have a million records you are wasting nearly 1 MB of space - for most of us that's not really too bad because we don't have that many records, but when you get onto systems like social insurance numbers and have 300 million people it really makes a difference.
Generally, if I'm using integers for things like record numbers then I would use INT(11) on the grounds that it is unlikely to run out of numbers. mysql is not daft either, it doesn't always store the number using the whole space, I think it uses just what it needs. You can also have it put default values in when a new record is written.
I'm not sure about wildcards - your query will pick up all the records that match what you ask for - you could do something like WHERE 1 = 1 and that will match every record . . .
your mysql question - depends on the type of data that you specify, the full overview of data types is here
dev.mysql.com/doc/refman/5.0/en/data-types.html
when you are setting up tables it's worth thinking about how much space they are going to take up. For instance with integers you can have a TINYINT which will hold integers in the range -128 to +127 or 0-255 if they are unsigned. There are various other integer formats that will take numbers that are huge. However, there is a price to pay because they take up more storage space - so for instance if you use a byte too many and have a million records you are wasting nearly 1 MB of space - for most of us that's not really too bad because we don't have that many records, but when you get onto systems like social insurance numbers and have 300 million people it really makes a difference.
Generally, if I'm using integers for things like record numbers then I would use INT(11) on the grounds that it is unlikely to run out of numbers. mysql is not daft either, it doesn't always store the number using the whole space, I think it uses just what it needs. You can also have it put default values in when a new record is written.
I'm not sure about wildcards - your query will pick up all the records that match what you ask for - you could do something like WHERE 1 = 1 and that will match every record . . .
Replied 02 May 2007 00:43:58
02 May 2007 00:43:58 Xeon 133 replied:
I do have more questions.
1. Im making a new posting script that uses a form to fill out, then a php script gets the info and writes it to mysql, then I have the home page get all of the posts from the MySql, and read them, Im trying to figure out a way to organize them by oldest post to newest post, I have tryed to use the date, but that was no luck when i posted multipul posts on the same day, it would put the newset post on the bottom. I am probly doing alot of steps that I dont have to, but im learning, so im doing what i can to do what i want it to do. Im trying to figure out if there is a way to have some php script that starts with #1, and when you post it will asign the post a number, and then the Index will show the posts as "ORDER BY id asc" or somthing like that to show it from the oldest post at the bottom to the newest post at the top.
2. For my script I am wanting to make a login panel, so that you have to login to use this script.
Im planing on using this script to make all new pages, and be able to edit the content on each page, The only problem I see is that Im going to have to make templates for this script, like I wont be able to make a new template for it unless I do alot of changing, and stuff.
Like on my home page, I have little Fancy boxes that each posts gets put into, I have the script write Html of the box, and info with each post, so that when you read the data, it will all show up the way i want it to.
I have made a panel for posting news with only PHP, but I really couldnt do what i want to do with just PHP, so im going to make it using MySql. Its kinda hard for me to explain.
1. Im making a new posting script that uses a form to fill out, then a php script gets the info and writes it to mysql, then I have the home page get all of the posts from the MySql, and read them, Im trying to figure out a way to organize them by oldest post to newest post, I have tryed to use the date, but that was no luck when i posted multipul posts on the same day, it would put the newset post on the bottom. I am probly doing alot of steps that I dont have to, but im learning, so im doing what i can to do what i want it to do. Im trying to figure out if there is a way to have some php script that starts with #1, and when you post it will asign the post a number, and then the Index will show the posts as "ORDER BY id asc" or somthing like that to show it from the oldest post at the bottom to the newest post at the top.
2. For my script I am wanting to make a login panel, so that you have to login to use this script.
Im planing on using this script to make all new pages, and be able to edit the content on each page, The only problem I see is that Im going to have to make templates for this script, like I wont be able to make a new template for it unless I do alot of changing, and stuff.
Like on my home page, I have little Fancy boxes that each posts gets put into, I have the script write Html of the box, and info with each post, so that when you read the data, it will all show up the way i want it to.
I have made a panel for posting news with only PHP, but I really couldnt do what i want to do with just PHP, so im going to make it using MySql. Its kinda hard for me to explain.
Replied 02 May 2007 02:32:50
02 May 2007 02:32:50 Alan C replied:
sounds like you are doing a good job to me - form picks up the info, then writes it to database, just what I would do.
I have to say that I find dates difficult in mysql, I know that some people will say they are easy but I do find difficulty with them sometimes.
What you could do is convert the date into a Unix timestamp - basically mysql stores DATE like this . . .
YYYYMMDD
and DATETIME as YYYYMMDDHHMMSS
full details are here
dev.mysql.com/doc/refman/5.0/en/datetime.html
then there is the TIMESTAMP datatype, which has differing properties. Something else you need to be aware of when using TIMESTAMP is that the first occurence of a TIMESTAMP within a record has special properties - it gets updated automatically every time that the record is updated. This can really mess you up if you want to record times which is just what you are doing.
I have something a bit like your table, it's a list of properties and managers can add records, so there are three fields that have the TIMESTAMP datatype, last_updated, created and expiry_date.
The last_updated gets set automatically every time the record is updated, but the other two I set with a query, so when the record is created they are both set to NOW(), then created is never updated, so I have a full YYYYMMDDHHMMSS value there, and I can adjust the expiry_date field by using mysql date arithmetic.
You can also convert the DATETIME to a unix time - that is an integer number of seconds starting on 1 Jan 1970, the number range allows for dates that run to about 2038 so it's safe enough. There are two mysql functions UNIX_TIMESTAMP() and FROM_UNIXTIME() that convert, so you could keep your existing fields but convert in the ORDER BY clause.
I think that would go something like ORDER BY UNIX_TIMESTAMP(field_containing_date_time) DESC - I've not used it so I can't be sure, one way to try it out is to use something like phpmyadmin, which lets you get directly at your database (use with care) and it has a section that allows you to enter queries and execute them directly - so you can test them out and make sure they work before coding them up, it even writes php for some queries.
Your idea of putting an id # in would work just great too, you could do it with the autoincrement facility, or even UNIX_TIMESTAMP(NOW()) - I just tried that in phpmyadmin and it returned 1178062116 I expect that's the correct number of seconds, put that into a field and you have an id that you can ORDER BY with confidence.
For your login script I'm not just sure what you want, but check out evolt.org there is a good php tutorial there based on a login system, that's what I started with, messed about with it and changed it beyond recognition to control access to pages. Still learning something new every day.
I have to say that I find dates difficult in mysql, I know that some people will say they are easy but I do find difficulty with them sometimes.
What you could do is convert the date into a Unix timestamp - basically mysql stores DATE like this . . .
YYYYMMDD
and DATETIME as YYYYMMDDHHMMSS
full details are here
dev.mysql.com/doc/refman/5.0/en/datetime.html
then there is the TIMESTAMP datatype, which has differing properties. Something else you need to be aware of when using TIMESTAMP is that the first occurence of a TIMESTAMP within a record has special properties - it gets updated automatically every time that the record is updated. This can really mess you up if you want to record times which is just what you are doing.
I have something a bit like your table, it's a list of properties and managers can add records, so there are three fields that have the TIMESTAMP datatype, last_updated, created and expiry_date.
The last_updated gets set automatically every time the record is updated, but the other two I set with a query, so when the record is created they are both set to NOW(), then created is never updated, so I have a full YYYYMMDDHHMMSS value there, and I can adjust the expiry_date field by using mysql date arithmetic.
You can also convert the DATETIME to a unix time - that is an integer number of seconds starting on 1 Jan 1970, the number range allows for dates that run to about 2038 so it's safe enough. There are two mysql functions UNIX_TIMESTAMP() and FROM_UNIXTIME() that convert, so you could keep your existing fields but convert in the ORDER BY clause.
I think that would go something like ORDER BY UNIX_TIMESTAMP(field_containing_date_time) DESC - I've not used it so I can't be sure, one way to try it out is to use something like phpmyadmin, which lets you get directly at your database (use with care) and it has a section that allows you to enter queries and execute them directly - so you can test them out and make sure they work before coding them up, it even writes php for some queries.
Your idea of putting an id # in would work just great too, you could do it with the autoincrement facility, or even UNIX_TIMESTAMP(NOW()) - I just tried that in phpmyadmin and it returned 1178062116 I expect that's the correct number of seconds, put that into a field and you have an id that you can ORDER BY with confidence.
For your login script I'm not just sure what you want, but check out evolt.org there is a good php tutorial there based on a login system, that's what I started with, messed about with it and changed it beyond recognition to control access to pages. Still learning something new every day.