Web Analytics Made Easy -
StatCounter I require a simple script that edits a file... - CodingForum

Announcement

Collapse
No announcement yet.

I require a simple script that edits a file...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • I require a simple script that edits a file...

    Ok I have a board that has this code:

    random stuff...
    if($powl>3) { $namecolor="color=003399"; } else {
    yet more random stuff
    Well I tried making the hex code appear thorugh sql but it just glitched almost all the board.

    So I need a script that edits that code into whatever code I type,like in editprofile.php,I make a field where I type the hex code and the code I type replaces the hex code in the file.

    So,anybody has an idea on how to make that? The file path is /lib/function.php

    Thanks.

  • #2
    If you explained in a less jibbery way exactly what you wanted then someone may help. This is rather hard to understand.

    ~Phil~
    Lusci.Com :: System Development Solutions

    Comment


    • #3
      Code to edit: if($powl>3) { $namecolor="color=003399"; } else {

      Let say in edit profile I make a new field called "Color"
      I go to edit profile put in "color" the hex code for the color I want to use,then when I click on save profile I want the code I typed replace this one:if($powl>3) { $namecolor="color=003399"; } else {

      Understand now?

      Comment


      • #4
        So, are you asking how does PHP use values from html <form> elements such as <input> and <select>?

        Here is a decent walkthrough for that concept:

        http://www.php.net/manual/en/tutorial.forms.php

        Comment


        • #5
          No,I know how to make fields in files like editprofile and stuff,what I want is that the code I type in that field replaces the one I stated earlier.

          Comment


          • #6
            Run the string through preg_replace()? I'm confused also thou...
            Active PHP/MySQL application developer available for immediate work.
            syosoft.com mavieo.com - Remote Web Site Administration Suite - Reseller Ready

            Comment


            • #7
              You can use the value from your form wherever you want (once the form has been submitted).

              PHP Code:
              if($powl>3) { $namecolor="color='".$_POST['colorfieldfromyourform']."'; } else { 

              Comment


              • #8
                No again.
                The color code lies in: lib/function.php
                The file im puting the script is:editprofile.php

                I cant put a variable in that code either,I tired this:
                $usercolor=mysql_query("SELECT color FROM users WHERE id=1");
                if($powl>3) { $namecolor="color=$usercolor"; } else {

                And it just glithed all the colors,and all things that require that code.
                So I dont want any "$" codes in there.

                Does the fopen code works with what I want?

                Comment


                • #9
                  Regarding the code you posted:
                  PHP Code:
                  $usercolor=mysql_query("SELECT color FROM users WHERE id=1");
                  if(
                  $powl>3) { $namecolor="color=$usercolor"; } else { 
                  $usercolor is assigned a query resource but not the data coming from the query. You need to use a fetch function for that (mysql_fetch_assoc() for example).

                  Comment


                  • #10
                    I already said queries dont work.I need a script that edits the number not mysql.

                    Comment


                    • #11
                      You didn't say that query doesn't work.

                      Perhaps if you got it working you'd get somewhere.

                      Comment


                      • #12
                        Originally posted by daguy View Post
                        Ok I have a board that has this code:

                        random stuff...
                        if($powl>3) { $namecolor="color=003399"; } else {
                        yet more random stuff
                        Well I tried making the hex code appear thorugh sql but it just glitched almost all the board.

                        So I need a script that edits that code into whatever code I type,like in editprofile.php,I make a field where I type the hex code and the code I type replaces the hex code in the file.

                        So,anybody has an idea on how to make that? The file path is /lib/function.php

                        Thanks.
                        Yes I did.
                        I ask does "fopen" and "fclose" work for what I want? And I also tried the mysql_fetch_assoc thing and it didnt work.

                        Comment


                        • #13
                          Am I thick? I ask because I still have no idea what the question is...
                          Active PHP/MySQL application developer available for immediate work.
                          syosoft.com mavieo.com - Remote Web Site Administration Suite - Reseller Ready

                          Comment


                          • #14


                            I thought I could help this guy, but it looks like he just wants to argue. It seemed like a simple problem of replacing a hard-coded hex value with a PHP variable... but now I don't know what he wants.

                            OP mentioned his/her script isn't working. "glitched almost all the board" is poetic (in the "all your bases are belong to us" vein) but too vague to decipher.

                            An obvious problem with OP's script is found and pointed out-- the reply is "YEAH YEAH I KNOW IT DOESN'T WORK, I ALREADY SAID IT DOESN'T WORK!" Which is an interesting response, given the fact if it was written correctly and actually worked, then the OP's problem might actually be solved.

                            But... whatever

                            Comment


                            • #15
                              I thought this was easy for profesionals >_>
                              in editprofile:
                              if($action=='saveprofile'){
                              mysql_query("UPDATE blablabla");
                              I want here: OPEN FILE "lib/function.php" EDIT LINE #389 " if($powl>3) { $namecolor="color=EE4444"; } else {"
                              SET EE4444 TO $usercolor wich is the color field and its consist of six digits.

                              Get it now,I want the obious fake code into a real php code that does work.
                              If its not possible then I'll have to recode the entire colors code,and it consist of three files.

                              Comment

                              Working...
                              X