Jump to content


array or database?

  • Please log in to reply
2 replies to this topic

#1 nick5449

  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 04 July 2006 - 06:21 AM

I'm new to php and have a few questions.  I want to have a page on my website where people can leave messages.  Can I simply do this with arrays in php or do I need to use a mysql database?  If I do need a database, do I need any extra software or can I just use a basic text editor and upload the code to the server?  Thanks

#2 Barand

  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 04 July 2006 - 06:52 AM

An array only exists while the current script is running. You are going to have to store the messages somewhere, either in a database table or in a text file (flat file).

A simple text editor will suffice but it's a lot better to use a specialist code editor.

Have a look at http://www.php-editors.com
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received


|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 .josh

  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 04 July 2006 - 06:57 AM

arrays do nothing for permanently storing values (such as messages from people).  yes, you would need to have a database that holds it, or at least store the information in a flatfile (like a text file). 

database option: it depends on what your hosting package is.  do you buy hosting from someone, or do you have your own computer setup as a server?  hosting packages usually always include the ability to setup at least one database. the software is already on their server.  Go to cpanel or contact your hosting provider for help. 

flatfile option: you would basically have a seperate file in your directory. you would then use php to open the file and get the contents and display it. if someone posts a new message, it would open the same file and add the new message into the file. 

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users