[PHP] Free XML and WDL classes/scripts

2009-02-18 Thread Anton Heuschen
What are some good php classes/scripts to work with:

Parsing XML data/files.
Building SOAP/WDML (Im not too familiar with this so still trying to
work it out)


So far, I have a class from :

PHP WSDL Generator - Version 1.1.0 b
http://www.protung.ro



Basically what I need to do is connect to/send some variables to a
server, then get response in XML format and work with this data again
(parse it)


Hope this gives a good indication what I need, now to get some
recomendations to some good free code to assist (or even some
SOAP/XML/PHP/WDL(WSDL) tutorials also maybe) please.


Thank you

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Assign 2 values from Mysql to an array

2009-03-06 Thread Anton Heuschen
This might sound trivial, but for the live of me cant seem to get it to
work, and I am not familiar with such a thing.

What I have is a query lets say :

select  country,name,population from USERS where id= 'some_id' ";


Now I want to assign the result to one set (The above example might have 3+
entries per telephone, thus what would be nice is something like an array of
:


[id][country][name]  = population .. or to be exact if I echo the
value for each id and country and name to get the population value


Like :

Array {

  [id] array {
 [country] array {
[0] = USA
  }
  [name] array {
 [0] = test

  }

}




I dont know something like that, maybe Im over comlicating the question now
even, the main thing is wondered was in the first place was with a standard
query and variable assign, from the query like:

select  country,name,population from USERS where id= 'some_id' ";

normally you would just assign each field to one variable. like

$country = result["country"]
$name = result["name"]


But now I want all 3 fields as one variable (which would be an array) ..but
how ?

I hope I have not totally confused the question now.

Thanks in advance


[PHP] How to work with Webservices (.asmx) server

2009-03-10 Thread Anton Heuschen
I am confused with XML-RPC / SOAP and WSDL ...

If you have a server with a script/file like test.asmx and some web
services ...below example of service format :

SOAP 1.2

The following is a sample SOAP 1.2 request and response. The
placeholders shown need to be replaced with actual values.

-  SAMPLE OF Web Service from the
server below :

SOAP 1.2

The following is a sample SOAP 1.2 request and response.  The
placeholders shown need to be replaced with actual values.




POST /webservice/GetData.asmx HTTP/1.1
Host: www.theserver.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length


http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope";>
  
http://localhost/WebService/";>
  string

  




HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length


http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope";>
  
http://localhost/WebService/";>
  string

  




 END OF SAMPLE




I spend about most of my time looking at SOAP, XML-RPC and the PHP
SOAP extension, like from here:

http://tutorial.jcwcn.com/Web-Design/PHP/XML-and-PHP/2008-08-15/10160.html


Most of these talk about request to the server and a script with .wsdl
extension ... but from the example SOAP 1.2 "framework" above
and the fact that the url to the web service is not a .wsdl file but
in fact a .asmx file, how on earth to you

1) post a request to the example above.
2) What do you use here now actually ? SOAP/XML-RPC/WSDL ? or is this
something else ? Its extremely confusing since this does
not seem to fit in with any of the examples, material on the net.

I basically need to call the service and pass "string" to the Input
parameter and get the response field.


Some examples using the PHP Soap class talk about setting the URI, the
host and the NS and I don't know from the example SOAP 1.2 fields
provided where this should be taken from.


Some guidelines to good documentation/howto or tutorials and/or some
examples and functions/class would be
appreciated immensely

Regards

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to work with Webservices (.asmx) server

2009-03-11 Thread Anton Heuschen
Thanks Thijs.

My Father is from the Netherlands, but I wont try it all in Dutch myself...

Ok slowly but surely and with your advice I start making sense of this, I am
still playing around with some tests and reading up. It should be real clear
and obvious once you get a working example I guess.

Thanks for your assistance and advice so far.

Regards


Now of to make myself a nice Hagelslag botterham to soothe my nerves ;-)

Anton

2009/3/11 Thijs Lensselink 

> Hoi Anton,
>
> Great job on the Dutch part :) But please keep the thread on list.
>
> You have set the server location when you create a SOAP client instance.
> Take a look at : http://php.net/manual/en/soapclient.soapclient.php
>
> So when instantiating the SOAP client object you pass as a second
> parameter. An array with as minimal settings the location and uri.
>
> I guess in your case it would be something like this:
>
> $client = new SoapClient(null, array(
>'location' =>  "http://localhost/WebService/GetData.asmx";,
>'uri'  => "http://localhost/WebService/";)
> );
>
> And if your webservice provides a WSDL file you can replace the null
> parameter for that one.
>
> Anton Heuschen wrote:
> > Dag.
> >
> > Dank U well.
> >
> > Lol and thats where my Dutch is going to end...
> >
> >
> > Thank you for the info, just one question that had me confused also and
> > that is to do with this
> >
> > the URL you actually are talking to with your SOAP client is
> > http://localhost/WebService/
> >
> >
> >
> > Ive seen that in material on the net too ... but I wondered so how does
> > your SOAP request know where to connect to ? should I not have the
> > target server URL (or is this also pointing to the Web Services Servers
> > WSDL not setup correctly and will my client only work if I run it from
> > the same PC? ) This is what confuses me so .
> >
> >
> > Regards
> >
> > 2009/3/10 Thijs Lensselink  p...@addmissions.nl>>
> >
> > Anton Heuschen wrote:
> > > I am confused with XML-RPC / SOAP and WSDL ...
> > >
> > > If you have a server with a script/file like test.asmx and some web
> > > services ...below example of service format :
> > >
> > > SOAP 1.2
> > >
> > > The following is a sample SOAP 1.2 request and response. The
> > > placeholders shown need to be replaced with actual values.
> > >
> > > -  SAMPLE OF Web Service from
> the
> > > server below :
> > >
> > > SOAP 1.2
> > >
> > > The following is a sample SOAP 1.2 request and response.  The
> > > placeholders shown need to be replaced with actual values.
> > >
> > >
> > >
> > >
> > > POST /webservice/GetData.asmx HTTP/1.1
> > > Host: www.theserver.com <http://www.theserver.com>
> > > Content-Type: application/soap+xml; charset=utf-8
> > > Content-Length: length
> > >
> > > 
> > > http://www.w3.org/2001/XMLSchema-instance";
> > > xmlns:xsd="http://www.w3.org/2001/XMLSchema";
> > > xmlns:soap12="http://www.w3.org/2003/05/soap-envelope";>
> > >   
> > > http://localhost/WebService/";>
> > >   string
> > > 
> > >   
> > > 
> > >
> > >
> > >
> > > HTTP/1.1 200 OK
> > > Content-Type: application/soap+xml; charset=utf-8
> > > Content-Length: length
> > >
> > > 
> > > http://www.w3.org/2001/XMLSchema-instance";
> > > xmlns:xsd="http://www.w3.org/2001/XMLSchema";
> > > xmlns:soap12="http://www.w3.org/2003/05/soap-envelope";>
> > >   
> > > http://localhost/WebService/";>
> > >   string
> > > 
> > >   
> > > 
> > >
> > >
> > >
> > >  END OF SAMPLE
> > >
> > >
> > >
> > >
> > > I spend about most of my time looking at SOAP, XML-RPC and the PHP
> > > SOAP extension, like from here:
> > >
> > >
> >
> http://tutorial.jcwcn.com/Web-Design/PHP/XML-and-PHP/2008-08-15/10160.html
> > >
>

Re: [PHP] How to work with Webservices (.asmx) server

2009-03-11 Thread Anton Heuschen
Who else eat Chocolate or (sugar even) on bread and eat liquorice sweets
full of salt ... having Dutch family and living with the culture gets lots
of frowns from South Africans here ...when you sit down and start sprinkling
sugar on your bread (if the budget is tight and you cant afford the good
stuff like choc-spreads and Hagel)...  The Zoute-drop is always a cool trick
here in South Africa ...people expect it to be sweet liquorice sweets ...its
the best to watch their faces once they realize the salty taste ...then you
look how long it takes them to spit it out.

Well thanks to all the help thus far ... now I feel depressed all of a suden
...miss the vibe -  Holland rocks

2009/3/7 Phpster 

> If you're not Dutch you're not much! Holland rocks!
>
> From a fellow dutchie,
>
> Bastien
>
> Sent from my iPod
>
>
> On Mar 11, 2009, at 4:47, Anton Heuschen  wrote:
>
>  Thanks Thijs.
>>
>> My Father is from the Netherlands, but I wont try it all in Dutch
>> myself...
>>
>> Ok slowly but surely and with your advice I start making sense of this, I
>> am
>> still playing around with some tests and reading up. It should be real
>> clear
>> and obvious once you get a working example I guess.
>>
>> Thanks for your assistance and advice so far.
>>
>> Regards
>>
>>
>> Now of to make myself a nice Hagelslag botterham to soothe my nerves ;-)
>>
>> Anton
>>
>> 2009/3/11 Thijs Lensselink 
>>
>>  Hoi Anton,
>>>
>>> Great job on the Dutch part :) But please keep the thread on list.
>>>
>>> You have set the server location when you create a SOAP client instance.
>>> Take a look at : http://php.net/manual/en/soapclient.soapclient.php
>>>
>>> So when instantiating the SOAP client object you pass as a second
>>> parameter. An array with as minimal settings the location and uri.
>>>
>>> I guess in your case it would be something like this:
>>>
>>> $client = new SoapClient(null, array(
>>>  'location' =>  "http://localhost/WebService/GetData.asmx";,
>>>  'uri'  => "http://localhost/WebService/";)
>>> );
>>>
>>> And if your webservice provides a WSDL file you can replace the null
>>> parameter for that one.
>>>
>>> Anton Heuschen wrote:
>>>
>>>> Dag.
>>>>
>>>> Dank U well.
>>>>
>>>> Lol and thats where my Dutch is going to end...
>>>>
>>>>
>>>> Thank you for the info, just one question that had me confused also and
>>>> that is to do with this
>>>>
>>>> the URL you actually are talking to with your SOAP client is
>>>> http://localhost/WebService/
>>>>
>>>>
>>>>
>>>> Ive seen that in material on the net too ... but I wondered so how does
>>>> your SOAP request know where to connect to ? should I not have the
>>>> target server URL (or is this also pointing to the Web Services Servers
>>>> WSDL not setup correctly and will my client only work if I run it from
>>>> the same PC? ) This is what confuses me so .
>>>>
>>>>
>>>> Regards
>>>>
>>>> 2009/3/10 Thijs Lensselink >>>
>>> p...@addmissions.nl>>
>>>
>>>>
>>>>   Anton Heuschen wrote:
>>>>
>>>>> I am confused with XML-RPC / SOAP and WSDL ...
>>>>>
>>>>> If you have a server with a script/file like test.asmx and some web
>>>>> services ...below example of service format :
>>>>>
>>>>> SOAP 1.2
>>>>>
>>>>> The following is a sample SOAP 1.2 request and response. The
>>>>> placeholders shown need to be replaced with actual values.
>>>>>
>>>>> -  SAMPLE OF Web Service from
>>>>>
>>>> the
>>>
>>>> server below :
>>>>>
>>>>> SOAP 1.2
>>>>>
>>>>> The following is a sample SOAP 1.2 request and response.  The
>>>>> placeholders shown need to be replaced with actual values.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> POST /webservice/GetData.asmx HTTP/1.1
>>>>> Host: www.theserver.com <http://www.theserver.com>
>>>>> Content-Type: application/soap+xml; charset=utf-8
>>>>> Content-L

[PHP] Pointers for NuSOAP

2009-06-22 Thread Anton Heuschen
Does anyone have any good links to basic and more advanced (and some
examples) of NuSOAP and using this ?

Would be appreciated to see some recommendations that might of helped
others etc.

Thank you in advance.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Pointers for NuSOAP

2009-06-22 Thread Anton Heuschen
Much appreciated Jonathan, going to look at it later tonight.

2009/6/22 Jonathan Tapicer :
> I've used this one, split in 4 parts:
>
> Introduction to NuSOAP: http://www.scottnichol.com/nusoapintro.htm
> Programming with NuSOAP: http://www.scottnichol.com/nusoapprog.htm
> Programming with NuSOAP Part 2: http://www.scottnichol.com/nusoapprog2.htm
> Programming with NuSOAP Using WSDL:
> http://www.scottnichol.com/nusoapprogwsdl.htm
>
> It's nice, and it has lots of working examples.
>
> Jonathan
>
> On Mon, Jun 22, 2009 at 11:02 AM, Anton Heuschen wrote:
>> Does anyone have any good links to basic and more advanced (and some
>> examples) of NuSOAP and using this ?
>>
>> Would be appreciated to see some recommendations that might of helped
>> others etc.
>>
>> Thank you in advance.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Echo result in a loop on each instance

2009-06-23 Thread Anton Heuschen
I have a question regarding echo of a var/string in a loop on each instance

A shortened example:

Lets say I have an array of values (rather big), and then I loop
through this array:

for or foreach :
{
   $value = $arrValAll[$i];

   echo "test".$i."--> ".$value;
}


When the script runs it will only start to echo values after certain
period ... it does not echo immediately ... how can I force it start
echo as soon as the first echo instance is done ? I thought ob_start
does this but I have tried it and not getting what I want.

Is there some other way/correct to do this?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Scope of Variables and use of global and this->var

2009-07-14 Thread Anton Heuschen
This is just a general question,

I am not 100% on when to use global $var , and $this->var  and how/what
about the GLOBAL vars 

Lets say I have one file I  call config.php here I connect to the db, to
ldap etc  the connection "var" I can then use in a file on its own ...
obviously after I include "config.php"   lets say in config.php my DB
connect was $dbconnect 

In my index.php page I then use $dbconnect again  but do I simply use
$dbconnect again ... or must I say global $dbconnect and then use it in the
rest of the DB calls? or use GLOBALS .. Within a class I can use $this->var
correct ... but its not something to be used in a basic "procedural" if I
can call it that page...


Lets say with my config.php and its connection to the db ...where I have
$dbconnect .. in a class I can also use it, do I access  this var
straight as $dbconnect or use $this->dbconnect = $dbconnect (and define it
as global $dbconnect first before doing this)

I am getting my results and seems to working most of the time, but not sure
if I am using calls to global or $this->var ..when its not required and
calling the var direct would of sufficed.

I have never really used GLOBAL vars, so not sure how this ties in or if it
might be even more helpful ...

Some suggestions or pointers or examples would be appreciated just to clear
up some confusion.


Regards

Oh and if one class uses methods in another class  do I instansiate a
new object of the other class  I have seen use of OtherClass::Method
  is this better method of $obj = new OtherClass()  use


[PHP] Freeing Memory

2009-07-30 Thread Anton Heuschen
How  would you go about ensuring the memory is not exhausted when running a
script ?

I have a script, which to make it basic ... reads values from files, I
create an array of values per file then with a foreach insert values into a
table, I have added a line to echo the memory use after each array is done
(after insert is done and the foreach is complete for the file) with: ->
echo "Mem SQL: ".memory_get_usage() . "\n";

It gave me this result below:

Mem SQL: 8341312
Mem SQL: 8461856
Mem SQL: 8693440
Mem SQL: 9327008
Mem SQL: 9798952
Mem SQL: 10238392
Mem SQL: 10604776

As can be seen the mem usage simply grows,

I have added a line after each iteration of the foreach is complete to unset
the vars and array ... thinking this would basically clear up the allocated
memmory used by the array ... and it would start at 0 again for the next
array looped, but obviously this is not quite the answer.

The question is then how do you "clear"  memmory then ?


[PHP] Using remote include config file and class in a local file

2009-11-03 Thread Anton Heuschen
Question is wrt to including a config file on an external server in a
local include

Lets say that on 127.0.0.1 I have test.php with

include http://200.200.1.1/Folder/Config.php

$obj = new RemoteClass()

do stuff


and on server 200.200.1.1 I have my Config.php file which is contains
the class RemoteClass() { echo "test" }



If I try to test it locally it says it cannot find RemoteClass ...


How can I include/require a config (or any other php classes file) on
my local running php script ?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Using remote include config file and class in a local file

2009-11-03 Thread Anton Heuschen
Yes your right ... realizing it ... the config file is a class I use
to connect to my Database  I want to store this config on myt
hosting and then I can link to it and use it at my office, or at my PC
at home

But I now realize including the php ...will just return a blank page
 so its not like doing a include(/config.php) when its local 

Anyway to do this ?



2009/11/3 Devendra Jadhav :
> You are including file from external server and you are accessing it via
> HTTP protocol. So it will include the output of
> http://200.200.1.1/Folder/Config.php and the output of that script is
> nothing.
>
> If you want to see the output just put http://200.200.1.1/Folder/Config.php
> in browser and check.
>
> btw what exactly you want to achieve by including external config file?
>
> On Tue, Nov 3, 2009 at 2:05 PM, Anton Heuschen  wrote:
>>
>> Question is wrt to including a config file on an external server in a
>> local include
>>
>> Lets say that on 127.0.0.1 I have test.php with
>>
>> include http://200.200.1.1/Folder/Config.php
>>
>> $obj = new RemoteClass()
>>
>> do stuff
>>
>>
>> and on server 200.200.1.1 I have my Config.php file which is contains
>> the class RemoteClass() { echo "test" }
>>
>>
>>
>> If I try to test it locally it says it cannot find RemoteClass ...
>>
>>
>> How can I include/require a config (or any other php classes file) on
>> my local running php script ?
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>
>
> --
> Devendra Jadhav
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Using remote include config file and class in a local file

2009-11-03 Thread Anton Heuschen
Hmmm yes thats another way of doing it ... Im running a Ubuntu box
..so its quite possible (how will you mount if your on XP?)



2009/11/3 Devendra Jadhav :
> You can you NFS to mount remote file system on your local system.
>
> On Tue, Nov 3, 2009 at 2:50 PM, Anton Heuschen  wrote:
>>
>> Yes your right ... realizing it ... the config file is a class I use
>> to connect to my Database  I want to store this config on myt
>> hosting and then I can link to it and use it at my office, or at my PC
>> at home
>>
>> But I now realize including the php ...will just return a blank page
>>  so its not like doing a include(/config.php) when its local 
>>
>> Anyway to do this ?
>>
>>
>>
>> 2009/11/3 Devendra Jadhav :
>> > You are including file from external server and you are accessing it via
>> > HTTP protocol. So it will include the output of
>> > http://200.200.1.1/Folder/Config.php and the output of that script is
>> > nothing.
>> >
>> > If you want to see the output just put
>> > http://200.200.1.1/Folder/Config.php
>> > in browser and check.
>> >
>> > btw what exactly you want to achieve by including external config file?
>> >
>> > On Tue, Nov 3, 2009 at 2:05 PM, Anton Heuschen 
>> > wrote:
>> >>
>> >> Question is wrt to including a config file on an external server in a
>> >> local include
>> >>
>> >> Lets say that on 127.0.0.1 I have test.php with
>> >>
>> >> include http://200.200.1.1/Folder/Config.php
>> >>
>> >> $obj = new RemoteClass()
>> >>
>> >> do stuff
>> >>
>> >>
>> >> and on server 200.200.1.1 I have my Config.php file which is contains
>> >> the class RemoteClass() { echo "test" }
>> >>
>> >>
>> >>
>> >> If I try to test it locally it says it cannot find RemoteClass ...
>> >>
>> >>
>> >> How can I include/require a config (or any other php classes file) on
>> >> my local running php script ?
>> >>
>> >> --
>> >> PHP General Mailing List (http://www.php.net/)
>> >> To unsubscribe, visit: http://www.php.net/unsub.php
>> >>
>> >
>> >
>> >
>> > --
>> > Devendra Jadhav
>> >
>
>
>
> --
> Devendra Jadhav
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Good SQL builder class

2009-12-04 Thread Anton Heuschen
Good day.

I'm looking for a good class to handle building dynamically from and
array (and if it is good it will automatically determine / or even
have different methods) to handle mutli-dimensional arrays or simple
associative arrays ... and build the SQL statement :

for example I have an array :

$home[$suburb]["street"] = test1;
$home[$suburb]["housenr"] =2;


Ok to keep it simple to 2, then I want to build the SQL like

insert into homes (STREET, HOUSENR) VALUES ($val1,$val2);


something like that, but I could also pass some array like :

$home["street"] = test2;
$home["housenr"] = 2;


but the idea stays the same = the index is the name of the DB fields
and the assigned value the element



I have looked on hotscripts and phpclasses but I have no idea how good
the solutions are that I have found thus far - therefor need some
recommendation from someone else past experience of this

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Remove blank lines from a file

2010-05-21 Thread Anton Heuschen
Hi Im trying do something like this, have a function which uploads my
file and returns file pointer ... but at same time ... I want to
remove all Blank lines in a file and update it before it goes to the
final location ...

What I tried was to do a write of file and use some regexp replace to
remove a blank ... either I am not doing the replace correct or my
understanding of the file buffer and what I can do with it between the
browser and saving is not correct,

Anyway my code looks something like this :


 $uploadfile = $this->uploaddir;
$mtran  = mt_rand(999,99);
$NewName= date("Ymd_Gis").$mtran.".csv";
$uploadfile = $uploadfile.$NewName;

try{
if
(move_uploaded_file($_FILES['attachfile']['tmp_name'], $uploadfile))
{
$handle = fopen($uploadfile, "r+");
$lines  = file($uploadfile,
FILE_SKIP_EMPTY_LINES); //FILE_IGNORE_NEW_LINES |
foreach ($lines as $line_num => $line) {
$line =
preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "", $line);
if(strlen($line) > 0)
$line=trim($line);
$line=$line."\n";
fwrite($handle, $line);
}
fclose($handle);

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Remove blank lines from a file

2010-05-21 Thread Anton Heuschen
On 21 May 2010 15:16, Ashley Sheridan  wrote:

>  On Fri, 2010-05-21 at 14:03 +0200, Anton Heuschen wrote:
>
> Hi Im trying do something like this, have a function which uploads my
> file and returns file pointer ... but at same time ... I want to
> remove all Blank lines in a file and update it before it goes to the
> final location ...
>
> What I tried was to do a write of file and use some regexp replace to
> remove a blank ... either I am not doing the replace correct or my
> understanding of the file buffer and what I can do with it between the
> browser and saving is not correct,
>
> Anyway my code looks something like this :
>
>
>  $uploadfile = $this->uploaddir;
> $mtran  = mt_rand(999,99);
> $NewName= date("Ymd_Gis").$mtran.".csv";
> $uploadfile = $uploadfile.$NewName;
>
> try{
> if
> (move_uploaded_file($_FILES['attachfile']['tmp_name'], $uploadfile))
> {
> $handle = fopen($uploadfile, "r+");
> $lines  = file($uploadfile,
> FILE_SKIP_EMPTY_LINES); //FILE_IGNORE_NEW_LINES |
> foreach ($lines as $line_num => $line) {
> $line =
> preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "", $line);
> if(strlen($line) > 0)
> $line=trim($line);
> $line=$line."\n";
> fwrite($handle, $line);
> }
> fclose($handle);
>
>
>
> If the files aren't too large in size, what about using something like
> file('somefile.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); which
> should pull into an array only those lines with content, and then just write
> that back out to the same file line by line?
>
>   Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>


Hi,

I actually had that ... removed it in last example as I was trying other
stuff and it did not seem to work either ?

$lines  = file($uploadfile, FILE_SKIP_EMPTY_LINES); //FILE_IGNORE_NEW_LINES
|


see I removed the FILE_IGNORE line - it was in earlier and only tried
FILE_SKIP_EMPTY  but still the final file had all the spaces again ...

So in the file it would look like (from the original file the user uploads
that is)

1
2

3
4


5

6


but when the file is saved to the server it must look like


1
2
3
4
5
6



but it never does and still looks like the first block.


[PHP] using passthru or system() even and passing the $_FILES array

2011-09-28 Thread Anton Heuschen
Good day,

I have a question and something that either does not work, or I have not
gotten it to work the way I want to.

I have a start page, which is a form, that takes 2 text fields and also a
Attachment field. Then it calls the first page, which is supposed to spawn
of a call to another page (I want to get the page to open server side see,
to allow the user to close the window, and the process continues in the
background) ...so I use either passthru or have now tried system().

The problem is that I can pass my 2 text fields as arguments to the call but
I have a problem in accessing and using $_FILES now to handle the file
defined.

I have tried to pass it to a $_SESSION["FILES"] , I have even tried to
serialize the whole array and pass it also as argument and build a array on
called php page, etc, but it does not seem to do anything, or handle the
file?


As further example, this is on the first page opened from the Form :

= php file 1 calling to file 2 =

session_start();
$_SESSION["FILES"] = $_FILES;
session_write_close();

$email  =   $_REQUEST['email'];
$actionDate =   $_REQUEST['actiondate'];
$files  =   serialize($_FILES);
$command = '/usr/bin/php -f /var/www/details/Write.php '.$email.'
'.$actionDate.' '.$files.' >> php.log';
system($command,$return);



=

then in my called file


 Write.php =

session_start();
$FILES = $_SESSION['FILES'];

$files1 = $FILES["coms1_attachfile"];
$filename1 = $files1;

==

$filename1 should now be recognized file name from a file provided in the
first form, and if statement then runs the file to process to read the file,
it seems here the process either does not get any file (so filename is never
true) or the file process have no file to work with.


So I am not really sure how passthru/system works with things like arrays
and sessions and $_FILES array etc