Re: [PHP] question about compositing objects
Hi, Jonathan! On Thu, 2006-01-12 at 14:13 -0800, jonathan wrote: > I have a class which creates another class within it such as: > > class Loc{ > > public function outputInfo() > { > > > $map=new Map(); > > $map->setKey(); > > > } > > } > > In my main page can I access the $map object like this: > > $loc=new Loc(); > > $loc->map->publicMapFunction(); Depending on what you're trying to accomplish, it looks like you're running into a scope issue. According to the code sample you provided, the $map object is local to the Loc::outputInfo() method. So, inside this method, you can access the $map object like $map->publicMapFunction() provided your Map class defines the publicMapFunction() method. If you want to access the $map object outside the outputInfo() method defined in the Loc class, then you'll need to return the $map object or provide some other interface to it within the Loc class. One way to do this would be something like this in the class definition: class Loc{ public function outputInfo() { $map = new Map(); $map->setKey(); return $map; } } Next, in your main page you might do this: $loc = new Loc(); $myMap = $loc->outputInfo(); Now, if you have the method publicMapFunction() defined in your Map class, you should be able to access it like this: $myMap->publicMapFunction(); I'm not sure the my example above is the best way to go about this...but without knowing exactly what it is you're trying to accomplish I think it at least should point you in the right direction. You'll also need to be aware of the difference between how PHP4 and PHP5 handle objects to know whether you're operating on a copy of an object or a reference to the actual object itself. Hope that helps! Tim -- Tim Boring IT Manager Automotive Distributors Warehouse 2981 Morse Road Columbus, OH 43230 direct: 614-532-4240 toll free: 800-421-5556 x 4240 e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help Desk software
On Wed, 2005-12-21 at 09:17 -0800, Daniel Lahey wrote: > I found one set of links that might prove helpful: http:// > www.helpdesk.com/software-helpdesk.htm A lot of the software doubles > as asset management software or comes bundled with such a module. > There are a yitload of links on that page. I'm only on the Bs. Good > luck. We use EnterTrack (http://www.entertrack.org) in my company. We've been using it for about 2 years and are pretty happy with it. I've also done some customization to our EnterTrack installation in order to integrate it with our company intranet. It's focus is on tracking/archiving issues, so it doesn't have any functionality for asset management. But it does have a pretty flexible group/permissions system that allows you to set up multiple groups and provides various levels of access to users. At one time, I evaluated phpMyInventory for asset management. There is the free version (http://phpmyinventory.sourceforge.net/index.php) and there is also a commercial version. We ended up going with Network Inventory Analyzer from Alloy (http://www.alloy-software.com/nin/pro.html). It's a commercial package, but it was inexpensive (~$1000 for 150 nodes) and met our needs. Hope that helps! Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [SOLVED]Problem with php.ini
On Tue, 2005-08-16 at 17:59 +0200, Torgny Bjers wrote: > Tim Boring wrote: > > >I'm having a problem with php-cli and php_mod reading my php.ini file. > >I've compiled php from source, during which process I set > >"--with-config-file=/etc". Once the compile completed, I then copied > >php.ini-recommened to /etc/php.ini. > > > >After restarting Apache, I run phpinfo() and "Configuration File Path" > >is showing only "/etc", which means it's not find /etc/php.ini. So then > >I tried the cli and ran phpinfo() from it and same thing. If I run it > >as "php -c /etc/php.ini", it can find/read it. > > > >For what it's worth, this is happening on a Gentoo system, but this > >shouldn't make too much of a difference since I've compiled PHP from > >source (v5.0.4), the same source I've used on a couple of other > >(non-Gentoo) machines. > > > >Just in case, here's the configure command I used: > >'./configure' '--with-apxs2=/usr/sbin/apxs2' '--disable-cgi' > >'--with-config-file-path=/etc' '--with-openssl' '--with-zlib' > >'-enable-bcmath' '--with-bz2' '--enable-calendar' '--enable-dba' > >'--with-db4' '--with-inifile' '--with-flatfile' '--enable-dio' > >'--enable-ftp' '--enable-gmp' '--with-unixODBC' '--with-pgsql' > >'--with-readline' '--enable-soap' '--enable-sockets' '--enable-wddx' > >'--with-xsl' '--with-pear' > > > >Any ideas? > > > > > > I think that --with-config-file-path is an absolute path to the php.ini > file, and not just a directory name, although, it ought to default to > php.ini, but perhaps when setting that directive it assumes that you are > specifying a custom configuration file, for instance /etc/php5_alt.ini > or /etc/my_php.ini instead of just php.ini. So, I think you should use > the --sysconfdir directive instead if you just want to specify where PHP > has its ini file. > > Regards, > Torgny > Okay, I resolved it by running "make clean" in the source directory and then re-running configure/make/make install. I think what happened was the first time I compiled it I didn't use the --with-config-file-path option, then went back and re-compiled with setting --with-config-file-path=/etc but without running "make clean" first. Thanks, Tim -- Tim Boring IT Manager Automotive Distributors Warehouse 2981 Morse Road Columbus, OH 43231 Toll Free: 800-421-5556, x3007 Direct: 614-532-4240 E-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with php.ini
I'm having a problem with php-cli and php_mod reading my php.ini file. I've compiled php from source, during which process I set "--with-config-file=/etc". Once the compile completed, I then copied php.ini-recommened to /etc/php.ini. After restarting Apache, I run phpinfo() and "Configuration File Path" is showing only "/etc", which means it's not find /etc/php.ini. So then I tried the cli and ran phpinfo() from it and same thing. If I run it as "php -c /etc/php.ini", it can find/read it. For what it's worth, this is happening on a Gentoo system, but this shouldn't make too much of a difference since I've compiled PHP from source (v5.0.4), the same source I've used on a couple of other (non-Gentoo) machines. Just in case, here's the configure command I used: './configure' '--with-apxs2=/usr/sbin/apxs2' '--disable-cgi' '--with-config-file-path=/etc' '--with-openssl' '--with-zlib' '-enable-bcmath' '--with-bz2' '--enable-calendar' '--enable-dba' '--with-db4' '--with-inifile' '--with-flatfile' '--enable-dio' '--enable-ftp' '--enable-gmp' '--with-unixODBC' '--with-pgsql' '--with-readline' '--enable-soap' '--enable-sockets' '--enable-wddx' '--with-xsl' '--with-pear' Any ideas? Thanks, Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] using require
Hello! On Fri, 2005-10-14 at 11:33 -0700, Cima wrote: > hi all, > > > i have my web site working something like this: in every php script i have > require(auth.php). this auth.php has my connection to my postgresql server > and database along with some other stuff i need for the user to be > authenticated to my web site. when i log on, this auth.php connects to the > dbserver and checks if my username and password are stored and then i go to a > home page. my connection is stored in $dbh. > what happens when i start moving through all these web pages (php scripts), > each requires auth.php, with respect to the connection? is a new connection > established for every web page i go into that uses my $dbh for querying > purposes or is it the same connection i originally made when i first logged > into the web site? > According to the manual (http://www.php.net/manual/en/function.pg-connect.php), you should be using the same connection. If I might make some recommendations: unless you're doing something unique as part of the login process, it might be worthwhile looking at the LiveAdmin authentication system. It's available via pear. It allows you to set up authentication containers, which can be an XML file holding your usernames/passwords, or a database like Postgres. It also has containers for permissions. I've tested in a couple of simple apps and it works fairly well. If LiveAdmin doesn't fit your needs, then you might look at Propel (http://propel.phpdb.org/trac/), it's an object persistence layer which provides a couple of benefits: 1) it abstracts your database so you don't have hand-coded SQL scattered throughout your PHP code and you don't have to mess around with the details of connecting to the db; 2) it provides a pretty sweet build tool that takes an SQL schema definition (marked up in XML) for a database and generates not only your SQL to create the tables but also your PHP classes. Then in your application you only need to be concerned with using the generated classes. I realize this isn't what you asked about, but I've used Propel in a couple of small web apps and I've been really happy with it. It cut the number of lines of code in my main application by almost half. Moreover, it helped simplify making changes to the db: if I need to change a field in a table, add/delete a field, or add a whole new table, I simply make the change in my schema file, re-generate my PHP classes, and then use the new classes in my app. I don't have to search through a bunch of code to find all the instances of a particular SQL statement. HTH, Tim > > any info will be highly appreciated!! > > > thanx. -- Tim Boring IT Manager Automotive Distributors Warehouse 2981 Morse Road Columbus, OH 43231 Toll Free: 800-421-5556, x3007 Direct: 614-532-4240 E-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Best practices for set/get methods
Does anyone have suggestions/ideas about best practices for writing set/get methods in PHP5? There are two basic ways I've seen this done, which I've provided examples of below. Method #2 is obviously the easier way, but that doesn't mean it may be the best way. I'm curious to read people's responses. Thanks, Tim #1: set/get method for each member attribute example: private $foo; private $bar; public getFoo() { return $this->foo; } public setFoo($val) { $this->foo = $val; } public getBar() { return $this->bar; } public setBar($val) { $this->bar = $val; } #2: generalized set/get methods example: private $foo; private $bar; public getVar($var) { return $this->$var; } public setVar($var, $val) { set $this->$var = $val; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with ftp_get and ftp_put over SSL--SOLVED
On Wed, 2005-02-23 at 15:58 -0500, Tim Boring wrote: > Hi, Richard! > > On Wed, 2005-02-23 at 08:45 -0800, Richard Lynch wrote: > > Maybe try the active/passive thing... > > > > Often-times, the client/server will/won't allow one or the other, based on > > their idea of what's safe/fast. > > Yes, I tried that, too. Sorry, I didn't mention that in my original > post. I appreciate the suggestion! It was in fact the active/passive thing! Being a newbie to phpunit2, I didn't realize that each test creates a new object; thus, although I had a test to test the passive function, the passive connection to the ftp server got destroyed with the object at the end of that test. So, I had to modify my test code to set the active connection to passive within each test. Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] FTP functions
Hello! On Mon, 2005-03-07 at 18:20 +0530, Vaibhav Sibal wrote: > Hi > I checked ou the ftp functions of PHP, what I wanted to ask was that > if I connect to a remote server and issue and ftp_fget() command the > file will be downloaded to the server running the PHP code and Apache > webserver or the client machine from which we are calling it ? In the > sense for example I have a client machine running on windows XP, I > launch the mozilla firefox browser in that and call for the > ftp_code.php on my server (http://server). The ftp_code.php contains a > code which connects to a remote ftp server and then using the > ftp_fget() function downloads a file from the remote server. Now where > will this file be downloaded ? The short answer is it would download it to the server, not the client on which Firefox is running. But if you were wanting to transfer the file to the client, I'd think you could do something creative like this: 1. Have your script download the file from the remote server. 2. Once the file has been downloaded, display a new page to the browser with a link to the file. 3. Then the user can click the link to retrieve/open the file. Now this may not be the best solution, it just happens to be what I could think of off the top of my head. There may be better ways to accomplish the same thing. Hope that helps! Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Web Browser Timeout on Upload Script
On Wed, 2005-02-23 at 22:54 +0100, Marek Kilimajer wrote: > Matt Cassarino wrote: > > Hi, > > > > I am running a simple Upload script in PHP using a HTML Form with a File > > field. The user can browse their computer and upload a file. It works > > great, except for large files, where the browser will timeout. The timeout > > appears to happen after about 5 minutes. Any ideas on how to get around > > this? > > > > Ideal solution would be on the server side b/c I don't want to have my > > users set a browser option. > > > > Thanks a lot! > > > Check your max_input_time setting. It cannot be changed at runtime using > ini_set(). > > http://docs.php.net/en/info.configuration.html#ini.max-input-time > Here's another link that might be useful. I came across this link searching through the archives. http://www.radinks.com/upload/config.php HTH, Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with ftp_get and ftp_put over SSL
Hi, Richard! On Wed, 2005-02-23 at 08:45 -0800, Richard Lynch wrote: > Maybe try the active/passive thing... > > Often-times, the client/server will/won't allow one or the other, based on > their idea of what's safe/fast. Yes, I tried that, too. Sorry, I didn't mention that in my original post. I appreciate the suggestion! Thanks, Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with ftp_get and ftp_put over SSL
I need to transfer files between a server at my company and one of our vendors. The vendor's running a SecureFTP (FTPS) server. In order to automate this from our side, I've created a class that wraps the ftp functions in an object. When I test my class on a standard FTP server, everything works fine: I can login, chdir, chmod, get/nb_get, put/nb_put, etc. However, when I connect to the vendor's server using ftp_ssl_connect (instead of ftp_connect), everything works fine with the exception of put/nb_put and get/nb_get. (I'm testing using PHPUnit2, and all my tests pass except for the get/put tests.) At first, I thought it may be a firewall issue, but I've checked the logs on our firewall and nothing is being logged as being blocked at that level. Also, the firewall rule is written in such a way that it's allowing all traffic to/from the vendor's server; so it doesn't appear like it's an issue with the data port not being open. I have verified that the same commands I'm using in my PHP code work using an FTP client, and they do. I've used lftp to connect to the vendor's FTPS server, chmod, chdir, get/put files...everything works fine. For the put/get commands, when I run my PHPUnit2 tests, I am getting the following output on the put/nb_put and get/nb_put commands: Warning: ftp_nb_put(): PORT command successful. in /home/tboring/scripts/ftp.class.php on line 490 Warning: ftp_put(): PORT command successful. in /home/tboring/scripts/ftp.class.php on line 587 Warning: ftp_get(): PORT command successful. in /home/tboring/scripts/ftp.class.php on line 399 Warning: ftp_nb_get(): PORT command successful. in /home/tboring/scripts/ftp.class.php on line 453 Here's the actual code from my test object for all 4 commands: function testNbput() { $this->FTP->nb_put("output.test", "output.test", FTP_ASCII); echo "\nTest Name: testNbput()\n"; $this->assertEquals(0, $this->FTP->getVar(error_code)); } function testPut() { $this->FTP->put('output.test', 'output.test', FTP_ASCII); echo "\nTest Name: testPut()\n"; $this->assertEquals(0, $this->FTP->getVar(error_code)); } function testGet() { $this->FTP->get("/tmp/test.txt", "test.txt", FTP_ASCII); echo "\nTest Name: testGet()\n"; $this->assertEquals(0, $this->FTP->getVar(error_code)); } function testNbget() { $this->FTP->nb_get("/tmp/test.txt", "test.txt", FTP_ASCII); echo "\nTest Name: testNbget()\n"; $this->assertEquals(0, $this->FTP->getVar(error_code)); } Here's the corresponding code from my class: function get($local_file, $remote_file, $mode) { if (isset($this->conn_id)) { if (ftp_get($this->conn_id, $local_file, $remote_file, $mode)) { $this->xfer_status = "FTP_FINISHED"; $this->last_file_downloaded = $remote_file; $this->error_code = 0; } else { $this->error_code = 11; $this->error_message = "Unable to get file $file using $mode."; } } else { $this->error_code = 7; $this->error_message = "There is no current connection to an FTP/FTPS server."; } } function nb_get($local_file, $remote_file, $mode) { if (isset($this->conn_id)) { $status = ftp_nb_get($this->conn_id, $local_file, $remote_file, $mode); while ($status == FTP_MOREDATA) { $status = ftp_nb_continue($this->conn_id); } if ($status != FTP_FINISHED) { $this->xfer_status = "FTP_FAILED"; $this->error_code = 11; $this->error_message = "Unable to download file $file using $mode."; } else { $this->xfer_status = "FTP_FINISHED"; $this->last_file_downloaded = $remote_file; $this->error_code = 0; } } else { $this->error_code = 7; $this->error_message = "There is no current connection to an FTP/FTPS server."; } } function nb_put($remote_file, $local_file, $mode) { if (isset($this->conn_id)) { $status = ftp_nb_put($this->conn_id, $remote_file, $local_file, $mode); while ($status == FTP_MOREDATA) { $status = ftp_nb_continue($this->conn_id); } if ($status != FTP_FINISHED) { $this->xfer_status = "FTP_FAILED"; $this->error_code = 11; $this->error_message = "Unable to upload file $file using $mode."; } else { $this->xfer_status = "FTP_FINISHED"; $this->last_file_uploaded = $local_file; $this->error_code = 0; } } else { $this->error_code = 7; $this->error_message = "There is no current connection to an FTP/FTPS server."; } } function put($remote_file, $local_file, $mode) { if ($this->conn_id) { if (ftp_put($this->conn_id, $remote_file, $local_file, $mode)) { $this->xfer_status = FTP_FINISHED; $this->last_file_uploaded = $local_file; $this->error_code = 0; } else { $this->xfer_status = FTP_FAILED; $this->error_code = 11; $this->error_message = "Unable to upload file $file using $mode."; } } else { $this->error_code = 7; $this->error
RE: [PHP] Seemingly weird regex problem
On Thu, 2005-01-20 at 15:13, Michael Sims wrote: > Tim Boring wrote: > > On Thu, 2005-01-20 at 13:41, Jason Wong wrote: > >> I suspect what you want to be doing is something like this: > >> > >> switch (TRUE) { > >> case ANY_EXPRESSION_THAT_EVALUATES_TO_TRUE: > >> ... > >> } > > > > Thanks for the suggestion, but I'm not sure that does what I'm looking > > for. I really think the problem is with my regex, not necessarily > > with the way I've constructed my switch statement. > > No, Jason is right. Your problem IS in the switch statement. You cannot use > it the > way you are trying to and get the results you're expecting. Each case > expression is > evaluated with the switch expression just as if you compared them with the > "==" > operator. In your case, you're comparing the return value of preg_match() > against > the $line string. This isn't what you want. > > Here's what happens. Say your $line contains the string "AKRN". Your regex > pattern > matches only if the line begins with a non-word character. "A" is definitely > a word > character, so the pattern does not match. preg_match returns an integer > indicating > the number of matches, which in this case is 0. > > To evaluate your case, PHP does the equivalent of: > > if ("AKRN..." == 0) > > which is actually TRUE. From: > > http://www.php.net/manual/en/language.types.string.php#language.types.string.convers > ion > > "If the string starts with valid numeric data, this will be the value used. > Otherwise, the value will be 0 (zero)." > > Since "AKRN" doesn't begin with valid numeric data, it is converted to 0 for > the > purposes of the comparison. Since 0 == 0 the case comparison evaluates to > true. > > When you switch it to begin with a number, PHP now uses that number. Say you > switch > it to "1AKRN". PHP then will compare 1 == 0 which is false. > > To accomplish what you want you'll have to change it to: > > switch (true) { > case ($total_counter <= 5): > ... > case (preg_match(...): > ... > > etc. as Jason suggested. Why don't you try it and see if it works? > > HTH I tried it and it worked as Jason explained. Sorry, I'm a little slow at times. Thanks for taking the time and effort to explain this in more detail! Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Seemingly weird regex problem
On Thu, 2005-01-20 at 13:43, Jason Wong wrote: > On Friday 21 January 2005 02:16, Tim Boring wrote: > > > It's perfectly legit to use expressions. Now perhaps there is something > > wrong with the regex I'm trying to use, but using a regex in and of > > itself is legal. > > http://www.php.net/manual/en/control-structures.switch.php > > Yes, but comparing those expressions to: > > switch ($line) > > where $line is a string, doesn't make sense. See my other post. Thanks, Jason! I'll try this and see what I get. Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Seemingly weird regex problem
On Thu, 2005-01-20 at 14:40, Bret Hughes wrote: > On Thu, 2005-01-20 at 12:43, Jason Wong wrote: > > On Friday 21 January 2005 02:16, Tim Boring wrote: > > > > > It's perfectly legit to use expressions. Now perhaps there is something > > > wrong with the regex I'm trying to use, but using a regex in and of > > > itself is legal. > > > http://www.php.net/manual/en/control-structures.switch.php > > > > Yes, but comparing those expressions to: > > > > switch ($line) > > > > where $line is a string, doesn't make sense. See my other post. > > > > Chaching ( sound of light bulb turning on) I see that in the example in > the manual it needs to be compared to true ( a boolean value) > > > switch (true) > > rather than switch ($line) > > What is not apparent to me is why the first case matches if the preg > fails. Wouldn't line evaluate to true in a boolean context? Yeah, the light bulb just turned on for me, too. I'll play around with this and change it to boolean, but it still bothers me. My thinking was that $line was the expression that I wanted the switch construct to evaluate based on each case statement. Thus, if the regex turned out to be true, then it matched that case and would perform whatever code was in that branch. Weirdest of all, however, is that I've gone into the source input file and changed the first "word" in each line from text to a numeric value. And the switch statement works just fine. Thanks for the help! Tim > > Bret -- Tim Boring IT Department, Automotive Distributors Toll Free: 800-421-5556 x3007 Direct: 614-532-4240 E-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Seemingly weird regex problem
On Thu, 2005-01-20 at 13:41, Jason Wong wrote: > On Friday 21 January 2005 01:52, Tim Boring wrote: > > Well the biggest problem in your code right now is your incomprehensible (to > me anyway) use of the switch construct. For a start I've no idea why you're > using ... > > > switch ($line) > > ... when your tests do not involve $line > > > case ($total_counter <= 5): I see your point, but the other tests do involve $line. This one that you reference I'm using for a "special need"--basically so I leave in the initial column headings from the report, because they would match several of the tests that would discard those lines. > > I suspect what you want to be doing is something like this: > > switch (TRUE) { > case ANY_EXPRESSION_THAT_EVALUATES_TO_TRUE: > ... > } Thanks for the suggestion, but I'm not sure that does what I'm looking for. I really think the problem is with my regex, not necessarily with the way I've constructed my switch statement. I say this because I have since changed the first word in each line from something like "AKRN" to a numeric value, and everything works just as I would expect it to. So it seems as if the "^" might be negating the \W+ part of the regex. Although that shouldn't be happening because "^" only acts as a negation when it's used inside brackets, at least according the documentation. Again, thanks for the suggestion! Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Seemingly weird regex problem
On Thu, 2005-01-20 at 12:59, Richard Lynch wrote: > Tim Boring wrote: > > Hello! I'm having an odd regex problem. Here's a summary of what I'm > > trying to accomplish: > > > switch ($line) > > { > > case ($total_counter <= 5): > > break; > >case preg_match("/^\W+/", $line): > > While it would be Really Nifty (tm) if PHP worked this way, as far as I > know, you can only have a CONSTANT in your case. > > switch($char){ > case 'X': echo "It was an X"; break; > } > > You can't just put arbitrary expressions there... > > Feel free to correct me if the Manual sez different. It's perfectly legit to use expressions. Now perhaps there is something wrong with the regex I'm trying to use, but using a regex in and of itself is legal. http://www.php.net/manual/en/control-structures.switch.php Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Seemingly weird regex problem
Hello! I'm having an odd regex problem. Here's a summary of what I'm trying to accomplish: I've got a report file generated from our business management system (Progress 4GL), one fixed-width record per line. I've got a php script that reads in the raw file one line at a time, and "strips" out any "unwanted" lines (repeated column headings, mostly). I'm stripping out unwanted lines by looking at the beginning of each line and doing the following: 1. If the line begins with a non-word character (\W+), discard it; 2. If the line begins with the word "Vendor", discard it; 3. If the line begins with "Loc", discard it; 4. If the line begins with a dash, discard it; 5. Else keep the line and write it to an output file. The way I've implemented this in code is via the code snippet below. The problem I'm encountering, however, is that any line that begins with a word, such as "AKRN", is matching rule #1, thus discarding the line. This is not what I want, but I'm having difficulty spotting my mistake. To try to help spot the issue, I put in the if(preg_match("/^\W+/", $line)) logic, and the weird thing is that this logic isn't outputting the line beginning with things like "AKRN", yet the same line is getting caught in the switch statement and being discarded. Any suggestions? while (!feof($input_handle)) { $line = fgets($input_handle); if (preg_match("/^\W+/", $line)) { echo "$line\n"; } switch ($line) { case ($total_counter <= 5): fwrite($output_handle, $line); $counter++; $total_counter++; break; // Rule #1: non-word character case preg_match("/^\W+/", $line): array_push($tossed_lines, $line); echo "Rule #1 violation\n"; $tossed_counter++; $total_counter++; break; // Rule #2: "Vendor" at beginning of line case preg_match("/^Vendor/i", $line): array_push($tossed_lines, $line); echo "Rule #2 violation\n"; $tossed_counter++; $total_counter++; break; // Rule #3: "Loc" at beginning of line case preg_match("/^Loc/i", $line): array_push($tossed_lines, $line); echo "Rule #3 violation\n"; $tossed_counter++; $total_counter++; break; // Rule #4: dash character at beginning of line case preg_match("/^\-/", $line): array_push($tossed_lines, $line); echo "Rule #4 violation\n"; $tossed_counter++; $total_counter++; break; default: fwrite($output_handle, $line); $counter++; $total_counter++; break; } } -- Tim Boring IT Department, Automotive Distributors Toll Free: 800-421-5556 x3007 Direct: 614-532-4240 E-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php