php-general Digest 16 Dec 2003 13:37:19 -0000 Issue 2476

Topics (messages 172770 through 172802):

CVS on Windows
        172770 by: Chris W. Parker
        172776 by: Mike Migurski
        172800 by: Adam i Agnieszka Gasiorowski FNORD

Re: 4 project questions - help appreciated
        172771 by: Justin French
        172773 by: Ryan A

Re: PHP and MySQL date
        172772 by: John W. Holmes

can't access a GET variable on function?
        172774 by: Louie Miranda
        172775 by: Chris

Your Opinion
        172777 by: Gerard Samuel

Re: PHP IDE?
        172778 by: erwin.scoutingnederland.nl

Help with where clause
        172779 by: Richard Kurth
        172780 by: Terence
        172781 by: Tom Rogers

Reporting in PHP
        172782 by: Mrunal Wagh
        172791 by: Jay Blanchard

Re: Q on RegExp & extended Char
        172783 by: Sven

Re: trouble parsing an XML document
        172784 by: alfredo
        172797 by: Sven

Re: logic for displaying hierarchical data (ala windows explorer)
        172785 by: Sven

Help on using PEAR DB
        172786 by: marc serra
        172790 by: Jay Blanchard

Re: Starting OOP
        172787 by: Daniel Pupius

Re: Opening large file problem - fopen
        172788 by: Kim Steinhaug
        172789 by: Jay Blanchard
        172794 by: Kim Steinhaug
        172796 by: Jay Blanchard
        172798 by: Eugene Lee
        172801 by: Kim Steinhaug

disable_functions problems
        172792 by: Alberto Ferrer

Round() behaviour issue
        172793 by: Scott McDaid
        172795 by: Eugene Lee
        172799 by: Ford, Mike               [LSS]

Importing from MIVA
        172802 by: Jose Maria Vazquez

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Hey everyone,

Sorry for the OT post but I don't know of any other lists where this
would be appropriate so I'm sending it here.

I will be interfacing with a CVS server not hosted on a Windows machine
(it will be a bsd/*nix variant) and frankly I've never used it. What
client do all you Windows people use? Also, how does it wotk in
conjuction with your favorite editor? (Mine is HTML-Kit.) Is it
necessary to run some command-line scripts to get the updates populated
to the CVS server?

Also, when working with CVS do you work directly on your local station
or on the remote server? Take for example my situation. I'm just running
plain win2k pro. and I don't have Apache OR PHP installed and I don't
want to install them either. I use HTML-Kit to ftp into my linux server
and work on the files that way.

>From the little reading I've done on CVS you download the entire source
tree and then sync your changes with everything else at a certain time.
If I have to download everything will I then have to move it all to a
PHP compatible server (i.e. the one I use for dev now)?

As I'm thinking about it, maybe an alternative would be to have the CVS
client on the dev server I currently use and then modify the files the
way I always do. Then when I'm ready to sync I can just ssh into the dev
server and run some scripts...

Some guidance in this area would be greatly appreicated!!


Thanks,
Chris.

--- End Message ---
--- Begin Message ---
>I will be interfacing with a CVS server not hosted on a Windows machine
>(it will be a bsd/*nix variant) and frankly I've never used it. What
>client do all you Windows people use? Also, how does it wotk in
>conjuction with your favorite editor? (Mine is HTML-Kit.) Is it necessary
>to run some command-line scripts to get the updates populated to the CVS
>server?

Tortoise is a popular CVS client for windows -- CVS commands are added to
the contextual menu in [[whatever windows calls its Finder]]. All of your
files are edited locally, using the editor of your choice. Tortoise
informs you of a file's status with regard to CVS by coloring its icon:
red for modified, green for unchanged, etc. It also works well with
Pageant, if you need to connect to the server via SSH and don't want to
hassle with your password everytime. Some editors provide built-in CVS
functionality, but in my experience with BBEdit, I've not found this to be
as useful as it sounds. YMMV.


>Also, when working with CVS do you work directly on your local station or
>on the remote server?
<snip>
>As I'm thinking about it, maybe an alternative would be to have the CVS
>client on the dev server I currently use and then modify the files the
>way I always do. Then when I'm ready to sync I can just ssh into the dev
>server and run some scripts...

It's probably best to do testing and development in one spot, and have the
CVS checkout live there. That way, you don't have to worry about file
consistency between your development and testing directories. Since you
don't intend to have writing and running happening in the same place, you
may find it more sane to learn the command-line CVS client and use it on
the remote server, so that you can be sure that the files you're checking
in are the ones that work.

One drawback of using CVS on the command line is that it has little
support for batch operations on groups of files; a lot of people who use
CVS like this create some variety of CVS status script they can use to
automate the process of finding new or modified files in a group of
directories. Mine is here:
        http://saturn5.com/mike/public/cvstatus.pl



---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca            http://mike.teczno.com/contact.html

--- End Message ---
--- Begin Message ---
"Chris W. Parker" wrote:
 
> I will be interfacing with a CVS server not hosted on a Windows machine
> (it will be a bsd/*nix variant) and frankly I've never used it. What
> client do all you Windows people use? Also, how does it wotk in
> conjuction with your favorite editor? (Mine is HTML-Kit.) Is it
> necessary to run some command-line scripts to get the updates populated
> to the CVS server?

        I'm using WinCvs, it has it's own file
 listings, so I don't have to deal with the
 awful awful Explorer shell (I prefer Windows
 Commander about 1000000 times). The URL to 
 the project is <url: http://www.wincvs.org/download.html >.
 If you want to edit a file, you just double click
 it and it opens in your configured editor. You can
 modify context menus any way you like and have
 all the most useful commands there, like Add,
 AddBinary, Commit, Update etc...It has support
 for Python scripts, too. Check it out.

-- 
Seks, seksić, seksolatki... news:pl.soc.seks.moderowana
http://hyperreal.info  { iWanToDie }   WiNoNa    )   (
http://szatanowskie-ladacznice.0-700.pl  foReVeR(  *  )
Poznaj jej zwiewne kształty... http://www.opera.com 007

--- End Message ---
--- Begin Message --- Ryan,

As usual, telling us more about the project will help. I'm a little confused about the key -- is it just a unique key, or is it some form of password, or somewhere in between?

Let's look at the flow...

1.      You send your pal a key in an email or whatever like so:
        http://www.site.com/view.php?key=123457890

2. they go to that URL, and view the message


What I don't understand is why the key needs to be so complicated. Surely starting at 1 and incrementing is enough? MySQL's in-built auto-increment makes life very easy to have a numbered unique key :)


Or perhaps you want something less predictable... like PHP's unique key function:
http://www.php.net/manual/en/function.uniqid.php



Before you even bother figuring out the queries, take a step back, and think long and hard about what you're trying to achieve. You sound like you're trying to invent something secure, but in reality, it's a mess, with predictable, plain-text keys.



If I wanted to publish a list of secret messages on a website, each message would have a unique ID (starting at one, and incrementing), a password (*at least* stored as an md5(), and not transmitted with the id), and finally the message field.


Even then, I still don't get it, so perhaps you need to tell us more.


Justin French



On Tuesday, December 16, 2003, at 05:43 AM, Ryan A wrote:


Hi,
I am making a personal project like so:

I enter something in the text box (eg. "PHP REALLLLLLY ROCKS!!!")
then the program checks if that string already exists in the database, if
no, then it should enter it into the database and also generate a "key"
This key can be given to pals and they can read the "secret message"


Key:
Key should first be 1-1000 then a-z then A-Z then axxx (eg: a001, the xxx
will always be numbers) once it reaches 999 it should become Axxx then b
then B etc after a,A,b,B are done it should go for aaxx,AAxx etc always 4
characters


A few questions:
1.Looking at the above (database part) I figured that doing this via a mysql
database would be better rather than a text database...do you agree?


2.I was thinking of making the "key" field a primary key and unique and
indexed....right?

3.The way I see it theres 3 sql statements that need to be run, a) connect
and see if string exists b)read the last key c)write to the
database...anyway to break the above to 2 statements or am I following this
wrong?


4. Logic for the key, I am coming up with crummy logic to make the "key",
basically a block of code for 1-1000,another block for a-z another block for
A-Z etc...... any ideas,links,URLs or code snippets off the top of your head
would be greatly appreciated.



Thanks in advance.


Cheers,
-Ryan

--- End Message ---
--- Begin Message ---
Hi Justin,
Yes, I admit the project sounds pretty screwy.

The project is needed for a clients son, he's a small twerp who wanted
something like this and since this is an old client who gave us quite a bit
of business, rather than say no and upset him...I took this on.

The key has to be a max of 4 chars and minimum of 1..
It has to be 1-9999 and a-z. I am well aware its easily "crackable" but its
for a kids game so...who cares?
According to the game, when you go to one address it tells you where to go
from there...going 1 after one will not make sense as the messages will then
be screwy.
Since its for kids and REAL security is not really wanted, i want to do this
in the simpliest fashion and not bother with MD5

The goal is, make it as fast as possible with as little effort as possible,
then wait for the dad to give me something really good..:-)

Cheers,
-Ryan



> Ryan,
>
> As usual, telling us more about the project will help.  I'm a little
> confused about the key -- is it just a unique key, or is it some form
> of password, or somewhere in between?
>
> Let's look at the flow...
>
> 1. You send your pal a key in an email or whatever like so:
> http://www.site.com/view.php?key=123457890
>
> 2. they go to that URL, and view the message
>
>
> What I don't understand is why the key needs to be so complicated.
> Surely starting at 1 and incrementing is enough?  MySQL's in-built
> auto-increment makes life very easy to have a numbered unique key :)
>
> Or perhaps you want something less predictable... like PHP's unique key
> function:
> http://www.php.net/manual/en/function.uniqid.php
>
>
> Before you even bother figuring out the queries, take a step back, and
> think long and hard about what you're trying to achieve.  You sound
> like you're trying to invent something secure, but in reality, it's a
> mess, with predictable, plain-text keys.
>
>
> If I wanted to publish a list of secret messages on a website, each
> message would have a unique ID (starting at one, and incrementing), a
> password (*at least* stored as an md5(), and not transmitted with the
> id), and finally the message field.
>
> Even then, I still don't get it, so perhaps you need to tell us more.
>
>
> Justin French
>
>
> On Tuesday, December 16, 2003, at 05:43  AM, Ryan A wrote:
>
> > Hi,
> > I am making a personal project like so:
> >
> > I enter something in the text box (eg. "PHP REALLLLLLY ROCKS!!!")
> > then the program checks if that string already exists in the database,
> > if
> > no, then it should enter it into the database and also generate a "key"
> > This key can be given to pals and they can read the "secret message"
> >
> > Key:
> > Key should first be 1-1000 then a-z then A-Z then axxx (eg: a001, the
> > xxx
> > will always be numbers) once it reaches 999 it should become Axxx then
> > b
> > then B etc after a,A,b,B are done it should go for aaxx,AAxx etc
> > always 4
> > characters
> >
> > A few questions:
> > 1.Looking at the above (database part) I figured that doing this via a
> > mysql
> > database would be better rather than a text database...do you agree?
> >
> > 2.I was thinking of making the "key" field a primary key and unique and
> > indexed....right?
> >
> > 3.The way I see it theres 3 sql statements that need to be run, a)
> > connect
> > and see if string exists b)read the last key c)write to the
> > database...anyway to break the above to 2 statements or am I following
> > this
> > wrong?
> >
> > 4. Logic for the key, I am coming up with crummy logic to make the
> > "key",
> > basically a block of code for 1-1000,another block for a-z another
> > block for
> > A-Z etc...... any ideas,links,URLs or code snippets off the top of
> > your head
> > would be greatly appreciated.
> >
> >
> > Thanks in advance.
> >
> > Cheers,
> > -Ryan
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

--- End Message ---
--- Begin Message --- Cesar Aracena wrote:

I tried what both of you told me and I found very easy to use the datetime
value under MySQL and then fetch it using strtotime() as fireball at
sizzling dot com recommended at the "User Contributed Notes" of php.net's
function.date.php page rather than using mktime() which can output incorrect
dates.

You can also use the MySQL function DATE_FORMAT() to format the MySQL timestamp to your liking. It is very similar to the PHP date() function.


--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
$emailto = $_GET['EmailTO'];

function wtemp_mainbody() {
    print "Contact (";
    echo "$emailto";
    print ") Info";
}

Why can't i display a GET variable from a function? Or should i registered
it on global session?




-- -
Louie Miranda
http://www.axishift.com

--- End Message ---
--- Begin Message ---
$emailto is in the global scope, so it's not accessible like that.

You can do it one of three ways:

$emailto = $_GET['EmailTO'];

function wtemp_mainbody() {
    global $emailto;
    print "Contact (";
    echo $emailto;
    print ") Info";
}
 or

$emailto = $_GET['EmailTO'];

function wtemp_mainbody() {
    print "Contact (";
    echo $GLOBALS['emailto'];
    print ") Info";
}
or (recommended)

function wtemp_mainbody() {
    print "Contact (";
    echo $_GET['EmailTO'];
    print ") Info";
}
-----Original Message-----
From: Louie Miranda [mailto:[EMAIL PROTECTED]
Sent: Monday, December 15, 2003 8:32 PM
To: [EMAIL PROTECTED]
Subject: [PHP] can't access a GET variable on function?


$emailto = $_GET['EmailTO'];

function wtemp_mainbody() {
    print "Contact (";
    echo "$emailto";
    print ") Info";
}

Why can't i display a GET variable from a function? Or should i registered
it on global session?




-- -
Louie Miranda
http://www.axishift.com

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

--- End Message ---
--- Begin Message ---
Looking to squeeze as much out of my core scripts (not that they are 
slow ;) ).
The thought arose that I can replace simple functions like
is_string(), is_array() with simpler php code.
For example ->
<?php

$foo = array('foo','foo','foo','foo','foo','foo','foo','foo','foo','foo',
                  'foo','foo','foo','foo','foo','foo','foo','foo','foo','foo',
                  'foo','foo','foo','foo','foo','foo','foo','foo','foo','foo');

for($x=0; $x < 50; $x++)
{
    if ($foo === @(array)$foo)
//    if (is_array( $foo ))
    {
        echo 'true<br />';
    }
    else
    {
        echo 'false<br />';
    }
}

?>

It seems to work, and debugging it via APD shows that it uses less resources.
Just an idea, nothing serious.
Thanks


--- End Message ---
--- Begin Message --- Chris W. Parker wrote:

Of all these things can it connect to FTP locations?

I tried it out but could only manage to open files from my local
harddrive which is exactly where my php files are not.



Try HTMLKit: it can connect to an ftp-server.
http://www.html-kit.com

Erwin Kerk
Web Developer

--- End Message ---
--- Begin Message ---
I need to know how I can do a where clause in a select statement for mysql
where
one of the fields can have two solutions. In the example below
field3 needs to equal all with a and also all with b. Can this be done and
if so how.
 I am stumped on this one.

select * from table where field1= '$this' and field2 = '$that' and field3 =
'a and b'

--- End Message ---
--- Begin Message ---
You should direct such queries to the MySQL mailing list as this is a PHP
list.

[EMAIL PROTECTED]

or try their website:
www.mysql.com

Your answer however is here:

http://www.mysql.com/doc/en/SELECT.html


----- Original Message ----- 
From: "Richard Kurth" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 16, 2003 4:30 PM
Subject: [PHP] Help with where clause


I need to know how I can do a where clause in a select statement for mysql
where
one of the fields can have two solutions. In the example below
field3 needs to equal all with a and also all with b. Can this be done and
if so how.
 I am stumped on this one.

select * from table where field1= '$this' and field2 = '$that' and field3 =
'a and b'

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

--- End Message ---
--- Begin Message ---
Hi,

Tuesday, December 16, 2003, 6:30:22 PM, you wrote:
RK> I need to know how I can do a where clause in a select statement for mysql
RK> where
RK> one of the fields can have two solutions. In the example below
RK> field3 needs to equal all with a and also all with b. Can this be done and
RK> if so how.
RK>  I am stumped on this one.

RK> select * from table where field1= '$this' and field2 = '$that' and field3 =
RK> 'a and b'


probably like:

select * from table where field1= '$this' and field2 = '$that' and (field3 =
'a' or field3 = 'b')

-- 
regards,
Tom

--- End Message ---
--- Begin Message ---
hi,
 
I am novice to PHP development, please could anybody tell me what reporting tools are used in PHP, as we use Crystal Reports in VB.
 
Is there any freeware reporting tools available?
 
Regards,
M
 

--- End Message ---
--- Begin Message ---
[snip]

         I  am novice to PHP development, please could anybody tell me
what reporting tools are used in PHP, as we use Crystal Reports in VB.
         
        Is there any freeware reporting tools available?
        [/snip]
         
        I am sure there are, have you Googled for PHP reporting tools? 


--- End Message ---
--- Begin Message --- Jswalter schrieb:

...
 - allow apostrophes, but only if preceded *and* followed by a Alpha/Extend
 - allow hyphen/dash, but only if preceded *and* followed by a Alpha/Extend
...

hi walter,
how about something like this:

<?php

$_alpha  = 'a-zA-Z';         // standard latin letters
$_xascii = '\x80-\xFF';      // extended ascii-codes
$_achar  = $_alpha.$_xascii; // allowed characters

$regex = '/^['.$_achar.']+(\'|-)['.$_achar.']+$/';

?>

hth SVEN
--- End Message ---
--- Begin Message --- hi,

Sven wrote:

> take a look at http://www.php.net/manual/language.variables.php:
> "A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores."
> so, a minus isn't allowed in varnames!
> hth SVEN



I agree with you but let me say the problem:
I'm parsing some XML documents, I'm not the writer of them and of DTD, who wrote them used some tags like: <REG-ORIG>
This is allowed in XML, but when I initialise varibles I need to use the same name of tags(also respect Case-sensitiveness).
This is a big compatibility problem, how can I do? I cannot change all the XML docs and the DTD.


bye
Alfredo

--- End Message ---
--- Begin Message --- Alfredo schrieb:
hi,

Sven wrote:

> take a look at http://www.php.net/manual/language.variables.php:
> "A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores."
> so, a minus isn't allowed in varnames!
> hth SVEN



I agree with you but let me say the problem:
I'm parsing some XML documents, I'm not the writer of them and of DTD, who wrote them used some tags like: <REG-ORIG>
This is allowed in XML, but when I initialise varibles I need to use the same name of tags(also respect Case-sensitiveness).
This is a big compatibility problem, how can I do? I cannot change all the XML docs and the DTD.


bye
Alfredo

hi alfredo,


maybe you can workaround with arrays? for keys you can use any string. so $xml['REG-ORIG'] is valid in php.

hth SVEN
--- End Message ---
--- Begin Message --- Chris W. Parker schrieb:

Hi everyone,

Last Friday I struggled for a long time with displaying some data that's
stored using the Modified Preorder Tree Traversal method. Without making
this email overly long and complicated (like my first draft was) I'd
like to simply ask if someone has any links or functions or instructions
they can give me on how to display my data in such a way.

I want the following:

Level 1A
|--Level 2A
|  \--Level 3A
|     |--Level 4A
|     |  \--Level 5A
|     \--Level 3B
|--Level 2B
|  \--Level 3C
\--Level 2C
   \--Level 3D

What I always end up with is this (or some variant of it):

Level 1A
|--Level 2A
|  \--Level 3A
|  |  |--Level 4A
|  |  |  \--Level 5A
|  |  \--Level 3B
|--Level 2B
|  \--Level 3C
\--Level 2C
|  \--Level 3D


Any help is appreciated.


Chris.

hi chris,
just some thoughts:
i assume you build your tree from leaves to root via recursive functions? if so you need a logic like this:


<?php

function isLastChild($self, $parent) {
    // check, whether $self is the last child of parent
    // return true or false
}

if (!isLastChild($parent, $grandparent)) {
    // draw your vertical line symbol
} else {
    // draw just a spaceholder
}
// following draw the label of $self

?>

hope you understand, what i mean?

hth SVEN
--- End Message ---
--- Begin Message ---
Hi,

 

I am Using PEAR DB and i got this error after I have upgraded php4 to php5.

 

Fatal error: Only variables or references can be returned by reference in
/var/www/php/lib/php/DB/common.php on line 766

 

Could anybody tell me what I can do to resolve that error.

 

Regards,

Marc.

 

 


--- End Message ---
--- Begin Message ---
[snip]
I am Using PEAR DB and i got this error after I have upgraded php4 to
php5.

Fatal error: Only variables or references can be returned by reference
in
/var/www/php/lib/php/DB/common.php on line 766

Could anybody tell me what I can do to resolve that error.
[/snip]

Go back to PHP4? We'd have to see some relevant code.

--- End Message ---
--- Begin Message ---
It would be a good idea to create a database abstaction class.  This means
that should you move your application to a different database you only have
to replace your database class, instead of recoding everything with the new
set of functions.  It can also be neater than using the mysql functions
directly.

You could use it as in a composite or an aggregated relationship.  Check out
http://www.phppatterns.com/index.php/article/articleview/15/1/1/ for some
useful information.

Also is it necessary to have $ponum sent to each function, how about
creating an attrbute of the class and setting it in the constructor
function.



"Mike Smith" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I've been doing procedural coding for a few month's, but perceive the
> need for OOP for some of the projects I've done. I'm starting out and
> and would like some feedback, before I tread down the wrong path. The
> books I'm looking at Professional PHP (Wrox), and Visual QuickStart PHP
> have examples, but I seem to need something more concrete so I've
> started a skeleton to rewrite a Purchase Order application. Here is the
> layout:
>
> <?php //pocode.php
> class PurchaseOrder
> {
> //Variables
> var $ponum; //This will be a $_SESSION variable if that matters
> var $item;
>
> function AddItem($ponum,$item){
> ...INSERT SQL CODE
> }
>
> function DeleteItem($ponum,$item){
> ...DELETE SQL CODE
> }
>
> function UpdateItem($ponum,$item){
> ...UPDATE SQL CODE
> }
>
> function ListItems($ponum){
> ...SELECT SQL CODE, RETURN RESULTS (ie.
> while($row=mssql_fetch_array($rst)){echo $row[0]....})
> }
>
> }
> ?>
>
> I would then include that in my page,
> and add items to a PO by doing something like
> <?php
> include('pocode.php');
> $po = new PO();
>
> If($_POST['submit']=='Add'){
> //A HTML Button next to a text box to add a line item
> $po->AddItem('12345','5063');
> }
>
> $po->ListItems('12345');
>
> ?>
>
> Do I have the basic concept right? This is like relearning to code.
> Perhaps I learned in a bad way if that's the case. Any especially good
> tutorials or books to recommend?
>
> Thanks

--- End Message ---
--- Begin Message ---
I found that the script accually breaks on this line :

[Mon Jul 14 12:17:26 2003] [error] PHP Notice:  INSERT INTO tbl_news
(band_id, date, heading,heading_eng, ingress,ingress_eng, body,body_eng)
VALUES (-1,"2003-07-14","TESTAMENT endelig til Norge!!!", "Spiller p Rock
in - spesial treat for the fans!", "", "", "Testament + support spiller pe
Rock In onsdag 30.juli. Grunnet opptatte strre spillesteder ensket Testament
likevel  gj/re Norge, med en kveld dedikert til fansen som har mttet vente
pt Norgesbesket i su mange r..
Rock In blir garantert utsolgt, sr her er det bare  hamstre billett ss fort
s mulig!!

Billetter pl billettservice/posten

Bill.pris 250,-+avg. - Drene cpner 19.00","") in
/home/xxx/public_html/admin/news_send.php on line 27
[Mon Jul 14 12:17:26 2003] [error] PHP Warning:  Cannot modify header
information - headers already sent by (output started at
/home/xxx/public_html/admin/news_send.php:2) in
/home/pilotman/public_html/admin/news_send.php on line 34

---

Hope this helpls.

-- 
Kim Steinhaug
---------------------------------------------------------------
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
---------------------------------------------------------------


"Kim Steinhaug" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello
>
> Im having real problems working with large files in PHP. At
> the moment Im trying to parse an error_log file, and it works
> like a charm, except that the scipt stopps after parsing around
> 70.000 lines, or around 8MB of data. Im using this :
>
> $file    = "error_log"; // 280MB file
> if($fp=fopen($file, "r+"))
> {
>  while($line=trim(fgets($fp)))
>   {
>      // Do the business
>    }
>
> }
>
> Surely this is not the way to work with e.g. a 280MB file. I solved the
> sollution by chopping the file into 7MB files, and adding a fileopen
> loop around the script above which solves my problem. But ->
> How do I parse the 280MB file all in 1 go?
>
> I have plenty of timeout and plenty of RAM in the php.ini file, so the
> problem isnt here.
>
> -- 
> Kim Steinhaug
> ---------------------------------------------------------------
> There are 10 types of people when it comes to binary numbers:
> those who understand them, and those who don't.
> ---------------------------------------------------------------

--- End Message ---
--- Begin Message ---
[snip]
I found that the script accually breaks on this line :

[Mon Jul 14 12:17:26 2003] [error] PHP Notice:  INSERT INTO tbl_news
(band_id, date, heading,heading_eng, ingress,ingress_eng, body,body_eng)
VALUES (-1,"2003-07-14","TESTAMENT endelig til Norge!!!", "Spiller p
Rock
in - spesial treat for the fans!", "", "", "Testament + support spiller
pe
Rock In onsdag 30.juli. Grunnet opptatte strre spillesteder ensket
Testament
likevel  gj/re Norge, med en kveld dedikert til fansen som har mttet
vente
pt Norgesbesket i su mange r..
Rock In blir garantert utsolgt, sr her er det bare  hamstre billett ss
fort
s mulig!!

Billetter pl billettservice/posten

Bill.pris 250,-+avg. - Drene cpner 19.00","") in
/home/xxx/public_html/admin/news_send.php on line 27
[Mon Jul 14 12:17:26 2003] [error] PHP Warning:  Cannot modify header
information - headers already sent by (output started at
/home/xxx/public_html/admin/news_send.php:2) in
/home/pilotman/public_html/admin/news_send.php on line 34
[/snip]

It does not seem to be the size of the file that you are working with,
there seems to be another problem. Turn on all error reporting. Use
mysql_error to echo errors from SQL statements. What is happening here
is that headers are being sent out and the script is exiting.

May I suggest sending in the code in question? Perhaps we can locate the
problem that way.

--- End Message ---
--- Begin Message ---
I found out that what the script accually does is choke on "\n\n",
empty lines. I havnt found a way to solve this with the script,

What I do now is use TextPad and just replace all occurencies
of "\n\n" with "\n-\n" or something and it works all nice. But this
is a bad way of doing it, since the script still doesnt accually work...

-- 
Kim Steinhaug
---------------------------------------------------------------
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
---------------------------------------------------------------


"Kim Steinhaug" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I found that the script accually breaks on this line :
>
> [Mon Jul 14 12:17:26 2003] [error] PHP Notice:  INSERT INTO tbl_news
> (band_id, date, heading,heading_eng, ingress,ingress_eng, body,body_eng)
> VALUES (-1,"2003-07-14","TESTAMENT endelig til Norge!!!", "Spiller p Rock
> in - spesial treat for the fans!", "", "", "Testament + support spiller pe
> Rock In onsdag 30.juli. Grunnet opptatte strre spillesteder ensket
Testament
> likevel  gj/re Norge, med en kveld dedikert til fansen som har mttet vente
> pt Norgesbesket i su mange r..
> Rock In blir garantert utsolgt, sr her er det bare  hamstre billett ss
fort
> s mulig!!
>
> Billetter pl billettservice/posten
>
> Bill.pris 250,-+avg. - Drene cpner 19.00","") in
> /home/xxx/public_html/admin/news_send.php on line 27
> [Mon Jul 14 12:17:26 2003] [error] PHP Warning:  Cannot modify header
> information - headers already sent by (output started at
> /home/xxx/public_html/admin/news_send.php:2) in
> /home/pilotman/public_html/admin/news_send.php on line 34
>
> ---
>
> Hope this helpls.
>
> -- 
> Kim Steinhaug
> ---------------------------------------------------------------
> There are 10 types of people when it comes to binary numbers:
> those who understand them, and those who don't.
> ---------------------------------------------------------------
>
>
> "Kim Steinhaug" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Hello
> >
> > Im having real problems working with large files in PHP. At
> > the moment Im trying to parse an error_log file, and it works
> > like a charm, except that the scipt stopps after parsing around
> > 70.000 lines, or around 8MB of data. Im using this :
> >
> > $file    = "error_log"; // 280MB file
> > if($fp=fopen($file, "r+"))
> > {
> >  while($line=trim(fgets($fp)))
> >   {
> >      // Do the business
> >    }
> >
> > }
> >
> > Surely this is not the way to work with e.g. a 280MB file. I solved the
> > sollution by chopping the file into 7MB files, and adding a fileopen
> > loop around the script above which solves my problem. But ->
> > How do I parse the 280MB file all in 1 go?
> >
> > I have plenty of timeout and plenty of RAM in the php.ini file, so the
> > problem isnt here.
> >
> > -- 
> > Kim Steinhaug
> > ---------------------------------------------------------------
> > There are 10 types of people when it comes to binary numbers:
> > those who understand them, and those who don't.
> > ---------------------------------------------------------------

--- End Message ---
--- Begin Message ---
[snip]
I found out that what the script accually does is choke on "\n\n",
empty lines. I havnt found a way to solve this with the script,

What I do now is use TextPad and just replace all occurencies
of "\n\n" with "\n-\n" or something and it works all nice. But this
is a bad way of doing it, since the script still doesnt accually work...
[/snip]

Are't those in each line of the file? If so it would choke right away.
Is it choking when placing this in the databse? You could handle it in
the script prior to the INSERT statement.

--- End Message ---
--- Begin Message ---
On Tue, Dec 16, 2003 at 01:30:14PM +0100, Kim Steinhaug wrote:
: 
: I found out that what the script accually does is choke on "\n\n",
: empty lines. I havnt found a way to solve this with the script,
: 
: What I do now is use TextPad and just replace all occurencies
: of "\n\n" with "\n-\n" or something and it works all nice. But this
: is a bad way of doing it, since the script still doesnt accually work...

You have two options:

1) massage your data beforehand so that your script works properly

2) buffer your input lines so that you process them only after you have
read a complete "entry", since one entry may span multiple lines in your
error_log.

--- End Message ---
--- Begin Message ---
Hello,

Thanks for you reply. The first approach works, I succesfully
imported 1.903.541 entries into my mySQL database, phew!
Problem was that as mentioned I had to "massage" the data
beforehand, which with TextPad didnt take to much time but
again I love my scripts to be complete and be "standalone".

Back to the 2) option, I tried another approach, just to see
how far the script woul accually go. There are ~2,1 million lines
in the error_log so I would like to see a result for the $i in this
range. But this script also chokes.

$file    = "error_log";
$handle = fopen ($file, "rb");
$contents = "";
do {
   $data = fread($handle, 8192);
   if (strlen($data) == 0) {
       break;
   }
   $contents = $data;
 $temp = explode("\n",$contents);
 $i = $i + count($temp);
 if($i%1000==0) // Spit out every 1000 lines count
 echo $i . "<br>";
} while(true);
fclose ($handle);
echo $count;
exit;

Do you have an example, or link to a site discussing the issue, of
buffering the data?

-- 
Kim Steinhaug
---------------------------------------------------------------
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
---------------------------------------------------------------


"Eugene Lee" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Tue, Dec 16, 2003 at 01:30:14PM +0100, Kim Steinhaug wrote:
> :
> : I found out that what the script accually does is choke on "\n\n",
> : empty lines. I havnt found a way to solve this with the script,
> :
> : What I do now is use TextPad and just replace all occurencies
> : of "\n\n" with "\n-\n" or something and it works all nice. But this
> : is a bad way of doing it, since the script still doesnt accually work...
>
> You have two options:
>
> 1) massage your data beforehand so that your script works properly
>
> 2) buffer your input lines so that you process them only after you have
> read a complete "entry", since one entry may span multiple lines in your
> error_log.

--- End Message ---
--- Begin Message ---
Hello, im testing the php_admin_value disable_functions froma Vhost in my Apache, and 
not works, is are set from Master (php.ini) works, but set via Apache vhost not works, 
any are using from apache php_admin_value disable_functions bla,bla,bla ?

-- 
--------------------------
     Alberto Ferrer
  [EMAIL PROTECTED]
 http://www.barrahome.org
JID: [EMAIL PROTECTED]
--------------------------
SNMP = Security? Not My Problem!

--- End Message ---
--- Begin Message ---
Hi there. I've been looking at the behaviour of the round functionality in 
PHP. We're currently still using v4.2.3, (but the documentation seems to 
suggest it's the same for versions after this).

Doing the following rounds always rounds *up* to the nearest whole number. 
i.e.

0.5 => 1
1.5 => 2
2.5 => 3
3.5 => 4

In earlier PHP docs, it stated that halves would be rounded to the nearest 
even number.
i.e. 

3.5 => 4
4.5 => 4

When did this change. Or is this *actually* the case in a version of PHP 
later than 4.2.3. I've had a look at the PHP changelog and the bug lists 
and found nothing. :(

I know I can work around this by adding a fuzz factor, but I'd rather not. 
I'm just confused as to why something so fundamental to math would change 
across PHP versions.

Kind Regards

Scott

-- 
Scott McDaid
lightershade
t: +44 131 514 4000
d: +44 131 514 4009

-- 

This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the sender. Any
offers or quotation of service are subject to formal specification.
Errors and omissions excepted.  Please note that any views or opinions
presented in this email are solely those of the author and do not
necessarily represent those of edNET or lightershade ltd. Finally, the
recipient should check this email and any attachments for the presence of
viruses.  edNET and lightershade ltd accepts no liability for any damage
caused by any virus transmitted by this email.

-- 
-- 
Virus scanned by edNET.

--- End Message ---
--- Begin Message ---
On Tue, Dec 16, 2003 at 11:13:25AM +0000, Scott McDaid wrote:
: 
: Hi there. I've been looking at the behaviour of the round functionality in 
: PHP. We're currently still using v4.2.3, (but the documentation seems to 
: suggest it's the same for versions after this).
: 
: Doing the following rounds always rounds *up* to the nearest whole number. 
: i.e.
: 
: 0.5 => 1
: 1.5 => 2
: 2.5 => 3
: 3.5 => 4

Any non-zero fractional component that gets rounded to the next whole
number is done with ceil().

: In earlier PHP docs, it stated that halves would be rounded to the nearest 
: even number.
: i.e. 
: 
: 3.5 => 4
: 4.5 => 4

I recall seeing those docs and getting very confused, especially with
your listed example.  Personally, I think the current behavior for
round() is mathematically correct; i.e. any number whose fractional
component is greater-than or equal-to 1/2 is rounded up to the next
whole number, otherwise it's rounded down.

--- End Message ---
--- Begin Message ---
On 16 December 2003 11:13, Scott McDaid wrote:

> Hi there. I've been looking at the behaviour of the round
> functionality in PHP. We're currently still using v4.2.3, (but the
> documentation seems to
> suggest it's the same for versions after this).
> 
> Doing the following rounds always rounds *up* to the nearest
> whole number.
> i.e.
> 
> 0.5 => 1
> 1.5 => 2
> 2.5 => 3
> 3.5 => 4
> 
> In earlier PHP docs, it stated that halves would be rounded
> to the nearest
> even number.
> i.e.
> 
> 3.5 => 4
> 4.5 => 4
> 
> When did this change. Or is this *actually* the case in a
> version of PHP
> later than 4.2.3. I've had a look at the PHP changelog and
> the bug lists
> and found nothing. :(

>From a quick peruse of the source in CVS, round() seems to have been
intended to round positive halves up and negative halves down since at least
PHP 4.0.0 -- although a bug-fix in 4.3.3 seems to suggest this might not
always have been happening in reality.  It seems likely that the reference
to rounding halves to the nearest even number was an error in the
documentation which has been fixed by removing it!

(http://bugs.php.net/bug.php?id=25694, which looks like it might be
relevant, is actually fixed by changing the behaviour of number_format()!)

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 

--- End Message ---
--- Begin Message ---
Hi there!

Does anyone know which is the best way to import orders from MIVA Merchant
into a MySQL DB? Currently, I'm using a Perl script that parses a plain file
generated by a script, but I'm looking for something more "professional"
like XML, Web-services, etc.

Thanks!

--- End Message ---

Reply via email to