Jump to content


Photo

Config File Help


  • Please log in to reply
3 replies to this topic

#1 vbnullchar

vbnullchar
  • Members
  • PipPipPip
  • Advanced Member
  • 428 posts
  • LocationPasig City, Philippines

Posted 07 September 2006 - 05:02 AM

hi everyone,

how can i read/write a config file
heres my config file
>> config.cfg <<

[topic]
title = "sample title"

[sub-topic]
sub_title = "sample sub title"

[rate]
rate1 = 1


thanks


Registered Linux User #399942
Ubuntu User #14134
--
my blog

#2 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 07 September 2006 - 05:51 AM

You might want to look into fread and fwrite.


Good Luck,
Tom

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#3 vbnullchar

vbnullchar
  • Members
  • PipPipPip
  • Advanced Member
  • 428 posts
  • LocationPasig City, Philippines

Posted 07 September 2006 - 06:53 AM

hi tom, thanks for the reply. how about if i want to modify a certain value.

Registered Linux User #399942
Ubuntu User #14134
--
my blog

#4 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 07 September 2006 - 08:02 AM

this is some what complex and you may run into serveral issues. What I would do is have a table in a db with the fields that I want in my file. Then if I need to change a certain field, I would update the db then rewrite the file.

It is easier to add a new line(with out a db.) then it is to edit a line. This is because if you are going to have multipule lines within your topic = "  "; it will be very difficult to read inbetween the "" .

Were as if you just rewrote the file from a db it would only take seconds and you would know that you got it right..


Good Luck,
Tom

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users