943,867 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 736
  • PHP RSS
Jan 17th, 2008
0

Alter many files, all with same variable in them

Expand Post »
I have 100's of files that access a field in a mySQL DataBase. I had to change the field name and now I have to update 100's of files. The files read:
PHP Syntax (Toggle Plain Text)
  1. $sql = 'SELECT user_id, username, user_colour, user_birthday FROM '
I need it to now read:
PHP Syntax (Toggle Plain Text)
  1. $sql = 'SELECT id, nick, user_colour, user_birthday FROM '

I know I could go through all files and execute a replace 'user_id' with 'id', but that would take forever. Does anyone know a program to do this easier?
Last edited by woocha; Jan 17th, 2008 at 11:04 am.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
woocha is offline Offline
48 posts
since Dec 2006
Jan 17th, 2008
0

Re: Alter many files, all with same variable in them

Off the top of my head, Dreamweaver has a search and replace (CTRL-F) function that will allow you to batch replace an entire folder/website/etc.

While you are finding and replacing, you might consider replacing 100 instances of the same code with an include path to a single script to make future revisions less painful.
Reputation Points: 14
Solved Threads: 14
Junior Poster in Training
johnsquibb is offline Offline
84 posts
since Nov 2007
Jan 17th, 2008
0

Re: Alter many files, all with same variable in them

If you're on linux then grep is your friend. Also as Johnsquibb said, if you have probably over 5 instances of identical code, put it in one file then just include it.
Sponsor
Reputation Points: 520
Solved Threads: 268
Code Monkey
ShawnCplus is offline Offline
1,564 posts
since Apr 2005
Jan 17th, 2008
0

Re: Alter many files, all with same variable in them

Click to Expand / Collapse  Quote originally posted by johnsquibb ...
Off the top of my head, Dreamweaver has a search and replace (CTRL-F) function that will allow you to batch replace an entire folder/website/etc.

While you are finding and replacing, you might consider replacing 100 instances of the same code with an include path to a single script to make future revisions less painful.
Hey..that sounds like a good idea. Do you have any advise on how to get started with something like that
Reputation Points: 10
Solved Threads: 0
Light Poster
woocha is offline Offline
48 posts
since Dec 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: without using input type=file can we upload the file
Next Thread in PHP Forum Timeline: Help! Parse error: parse error, unexpected T_STRING





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC