php-general Digest 20 Sep 2003 17:34:41 -0000 Issue 2308

Topics (messages 163271 through 163298):

Re: Problem with getting non-blocking data from stdin
        163271 by: Dan Anderson
        163272 by: Robert Cummings
        163273 by: Robert Cummings
        163274 by: Curt Zirzow
        163275 by: Robert Cummings
        163276 by: Dan Anderson
        163278 by: Curt Zirzow
        163279 by: Curt Zirzow
        163281 by: Robert Cummings
        163282 by: Robert Cummings
        163284 by: Eugene Lee
        163290 by: Marek Kilimajer

Re: Do PHP boolean operators short circuit?
        163277 by: Jason Wong
        163280 by: Curt Zirzow

Re: Clear ALL Cookies previously set
        163283 by: Eugene Lee

Slashdot:: PHP usage in the Enterprise - results
        163285 by: Alexandru COSTIN

Enterprise PHP market research results
        163286 by: Alexandru COSTIN

Re: Best way to approach object construction errors?
        163287 by: Marco Schuler

php.net
        163288 by: Paul Marinas

PhpProblem
        163289 by: Yonis Rouma

Using PHP to compile uploaded sourcecode with cygwins gcc?
        163291 by: DvDmanDT

Subcategories in php
        163292 by: phpu
        163293 by: Greg Donald
        163294 by: Larry E. Ullman

preg_replace question
        163295 by: Armand Turpel
        163296 by: Jim Lucas
        163298 by: Armand Turpel

session_start() || shell access problem......
        163297 by: CF High

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 ---
One more thing:

gdb doesn't do a damned thing for debugging PHP scripts.  Look for the
errors and warnings output to the browser.  (or tty if you're using
/usr/bin/php).  

-Dan

On Sat, 2003-09-20 at 00:33, Robert Cummings wrote:
> I wanted t play around with the CGI (not CLI) version of PHP and get a
> feel for the I/O stuff, specifically STDIN. So I whipped up the
> following script:
> 
> ///////////////////////////////////////////////////////////////////
> 
> #!/usr/bin/php -qC
> <?
>   
>     if( ($stdin = fopen( 'php://stdin', 'r' )) === false )
>     {                                                     
>         echo 'Failed to open STDIN'."\n";
>         exit();
>     }          
>      
>     stream_set_blocking( $stdin, false );
>                                          
>     $count = 0;                          
>     while( 1 ) 
>     {         
> echo 'Foo: '.($count++)."\n";
>         if( ($char = fread( $stdin, 1 )) !== false )
>         {
>             echo $char."\n";
>         }
>         else
>         {
>             echo 'Fooo!'."\n";
>         }
>     }    
> 
> ////////////////////////////////////////////////////////////////////
> 
> Simple enough right?! The problem is the program exits seemingly
> randomly. The last value for $foo can be anywhere from 400 to 1500. Even
> more strange is that running it through gdb indicates a successful exit,
> with no problems or core dumps. Anyone had any similar experiences? I'm
> running PHP 4.3.3 (cgi) -- the latest download version.
> 
> Cheers,
> Rob.
> -- 
> .------------------------------------------------------------.
> | InterJinn Application Framework - http://www.interjinn.com |
> :------------------------------------------------------------:
> | An application and templating framework for PHP. Boasting  |
> | a powerful, scalable system for accessing system services  |
> | such as forms, properties, sessions, and caches. InterJinn |
> | also provides an extremely flexible architecture for       |
> | creating re-usable components quickly and easily.          |
> `------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
On Sat, 2003-09-20 at 00:59, Dan Anderson wrote:
> Why are you using php:// below?  If stdin is a file './stdin' will

Because it is the correct way to retrieve input from standard input.

    http://www.php.net/wrappers.php

> suffice (or the path instead of ./).  If you want to run the PHP script
> in stdin you should use one of the following:
> include()
> include_once()
> require()
> require_once()
> See the manual at php.net for pertinent sections...

I don't want to run a script from stdin, I want to retrieve user input
from the keyboard. What the heck are you smoking?

> >     if( ($stdin = fopen( 'php://stdin', 'r' )) === false )
> >     {                                                     
> >         echo 'Failed to open STDIN'."\n";
> >         exit();
> >     }          
> 
> I seem to remember stream_set_blocking being either experimental or deprecated.
> If I remember correctly its for use with the function fsock_open().
> >     stream_set_blocking( $stdin, false );

No stream_set_blocking() is the correct function. The others are
deprecated because they are less generic for streams:

    This function was previously called as set_socket_blocking()
    and later socket_set_blocking() but this usage is deprecated.

> >     $count = 0;                          
> WTF are you thinking?  You really need to read the documentation. 
> Instead of this:

You sir, are a moron, you are calling me a moron and yet you are the one
who doesn't know what you are talking about.

> >     while( 1 ) 
> >     {         
> > echo 'Foo: '.($count++)."\n";
> >         if( ($char = fread( $stdin, 1 )) !== false )
> >         {
> >             echo $char."\n";
> >         }
> >         else
> >         {
> >             echo 'Fooo!'."\n";
> >         }
> >     }    
> 
> Try:
> 
> <?php
> 
> $stdin = fopen("./stdin","r");
> while ($stdin AND (!(feof($stdin))))
> { echo fread($stdin,4096); }
> 
> ?>
> 
> Much simpler, correct?

This is not what I want, I want individual keystrokes as they come in
form the keyboard. I'm quite sure I know what I'm doing.

> BTW: The infinite loop you have above could be the reason your script is
> acting erratically.  PHP kills off scripts after they run for so long --
> you may just be catching it in different versions of the loop.

Infinite loop, shmoop, the script ran for less than a second. Long
enough for $count to get as high as 2000 tops. I've run many, MANY
scripts as CGI shell script, and never has it bailed from an infinite
loop successfully in less than a second.

> Also BTW: I understand what you mean when you say CGI but not CLI
> version of PHP, but I really don't think the term CGI applies in this
> case.  CGI means Common Gateway Interface -- or a way to execute
> programs in a special directory designed to keep them from r00ting the
> system.  In PHP things such as headers are automatic -- no need to type:

I use the term CGI for the mode in which PHP was compiled, NOT, AND I
REPEAT NOT, because I'm using it as a Common Gateway interface.

> print "Content-type: text/html\n\n";
> 
> It's a server side scripting language designed to be embedded in things
> like web pages and be able to be run without much security concerns. 
> (i.e. not running a CGI perl scrip as /usr/bin/perl (i.e. not in tainted
> mode) -- ouch!  and these are the silly things users sometimes do)

Thanks for the lesson, I'll be sure to pretend I didn't know what CGI
is. BTW, if I were a newbie at PHP, your message would make me never
want to make another post. Even in the event you are correct, such a
pathetic response is no way to treat those of lesser knowledge. Now go
read the docs, and learn some more before trying to tell me what's what.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
On Sat, 2003-09-20 at 01:01, Dan Anderson wrote:
> One more thing:
> 
> gdb doesn't do a damned thing for debugging PHP scripts.  Look for the
> errors and warnings output to the browser.  (or tty if you're using
> /usr/bin/php).  

Oh you had to tie another on on. I guess I look really stupid. Hmmm
maybe I forgot to run gdb on the PHP binary instead of on the script. Oh
yes, that's got to be it. I ran gdb on the script, and once again I'm
stupid. Now I'm off to say a prayer that you don't inundate me with more
crap.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
* Thus wrote Robert Cummings ([EMAIL PROTECTED]):
> I wanted t play around with the CGI (not CLI) version of PHP and get a
> feel for the I/O stuff, specifically STDIN. So I whipped up the
> following script:
> 
> ///////////////////////////////////////////////////////////////////
> 
> #!/usr/bin/php -qC
> <?
>   
>     if( ($stdin = fopen( 'php://stdin', 'r' )) === false )
>     {                                                     
>         echo 'Failed to open STDIN'."\n";
>         exit();
>     }          
>      
>     stream_set_blocking( $stdin, false );

I believe this is not needed, stdin is nonblocking all the time.

>                                          
>     $count = 0;                          
>     while( 1 ) 

this will never exit until php runs out of memory, and most likely
will lead to unexpected results.

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
On Sat, 2003-09-20 at 01:52, Curt Zirzow wrote:
> * Thus wrote Robert Cummings ([EMAIL PROTECTED]):
> > I wanted t play around with the CGI (not CLI) version of PHP and get a
> > feel for the I/O stuff, specifically STDIN. So I whipped up the
> > following script:
> > 
> > ///////////////////////////////////////////////////////////////////
> > 
> > #!/usr/bin/php -qC
> > <?
> >   
> >     if( ($stdin = fopen( 'php://stdin', 'r' )) === false )
> >     {                                                     
> >         echo 'Failed to open STDIN'."\n";
> >         exit();
> >     }          
> >      
> >     stream_set_blocking( $stdin, false );
> 
> I believe this is not needed, stdin is nonblocking all the time.

My original test script didn't set the blocking state to non blocking. I
determined from that that stdin is initally in a blocking state. Since I
typed several characters and none where printed till I hit enter.

> 
> >                                          
> >     $count = 0;                          
> >     while( 1 ) 
> 
> this will never exit until php runs out of memory, and most likely
> will lead to unexpected results.

Yeah, it was just a test script. But still, if the memory had been
exhausted, it wouldn't be in under a second, and I'd get a core dump
like I usually do when I have a runaway recursive function.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
I find your responses to my e-mails quite humorous.  Upon review --
aside from a single WTF -- I don't think I was condescending in any way
shape or form.  I was just trying to offer help.

After reading about wrappers, I find it doubly humorous that you didn't
just disregard my e-mail when I asked you why you were using "php://". 
It's not like I said: "php://" isn't a valid protocol.  "http://"; and
"ftp://"; are all PHP supports.  I just said "Why are you using php://"
below?

And I also qualified my statements about fsockopen() and
set_stream_blocking by saying "I seem to remember" and "If I remember
correctly".  And, yes, in PHP 3.0 or whatever it was that was true. 
Hence the "if I remember".

So, it would seem to me that as soon as you got to the WTF you should
have said, "This guy thinks I am a noob".  And at that point you should
have just said "thanks but you're wrong". 

And, just for the record, you never explicitly stated that you needed a
reason to read in only one character at a time.  You just sent a bunch
of code down the pipe.  So it seems quite natural to assume you're just
making a noobish mistake -- reading a char at a time when a string will
do.

Anyways, you are running an infinite loop and I don't quite see how this
is exiting:

while (1) 
{
if ()
else
}

But, hey, more power to you if you've gotten to the level where you
don't understand why people who don't understand some esoteric function
are such muppets.

BTW: If you insist on keeping up with the flamethrowers kindly e-mail me
off list so as not to bother others on the listserv.

-Dan

--- End Message ---
--- Begin Message ---
hmm.. on second thought...

* Thus wrote Robert Cummings ([EMAIL PROTECTED]):
> [...]
>         if( ($char = fread( $stdin, 1 )) !== false )

How are you calling this script?  I'm not sure how cgi will handle
fread <stdin>

With a traditional CGI script <stdin> is what is read on POST data
from a form, and php takes care of this.

That is where my confusion is now.

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
* Thus wrote Dan Anderson ([EMAIL PROTECTED]):
> I find your responses to my e-mails quite humorous.  Upon review --

hmm... its almost (is) saturday lets all drop it.

cheers.

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
On Sat, 2003-09-20 at 02:02, Curt Zirzow wrote:
> hmm.. on second thought...
> 
> * Thus wrote Robert Cummings ([EMAIL PROTECTED]):
> > [...]
> >         if( ($char = fread( $stdin, 1 )) !== false )
> 
> How are you calling this script?  I'm not sure how cgi will handle
> fread <stdin>
> 
> With a traditional CGI script <stdin> is what is read on POST data
> from a form, and php takes care of this.
> 
> That is where my confusion is now.

I'm calling it as "php -qC foo.php". The fread() should work since it
works on input when I don't have stdin in non-blocking mode. Perhaps
it's a bug. I took a look at the doc on streams again, and it uses
php://input as the POST stream. Maybe it's a bug.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
On Sat, 2003-09-20 at 01:53, Dan Anderson wrote:
> I find your responses to my e-mails quite humorous.  Upon review --
> aside from a single WTF -- I don't think I was condescending in any way
> shape or form.  I was just trying to offer help.

The particular shape of your help was non newbie friendly. I think that,
combined with your incorrect assessments made it all the more annoying.
And yes, "WTF" and "you really need to read the documentation" played a
key part also since they were quite condescending, and inappropriate
given your incorrect answers and knowledge of functionality.

> After reading about wrappers, I find it doubly humorous that you didn't
> just disregard my e-mail when I asked you why you were using "php://". 
> It's not like I said: "php://" isn't a valid protocol.  "http://"; and
> "ftp://"; are all PHP supports.  I just said "Why are you using php://"
> below?
> 
> And I also qualified my statements about fsockopen() and
> set_stream_blocking by saying "I seem to remember" and "If I remember
> correctly".  And, yes, in PHP 3.0 or whatever it was that was true. 
> Hence the "if I remember".

Yes a lovely weasel statement if ever I saw one.

> 
> So, it would seem to me that as soon as you got to the WTF you should
> have said, "This guy thinks I am a noob".  And at that point you should
> have just said "thanks but you're wrong". 

Actually at that point I thought, "this guy thinks I'm an noob" and he's
being an arse about it. That's no way to treat noobs that post
appropriate questions.

> And, just for the record, you never explicitly stated that you needed a
> reason to read in only one character at a time.  You just sent a bunch
> of code down the pipe.  So it seems quite natural to assume you're just
> making a noobish mistake -- reading a char at a time when a string will
> do.

I certainly explained quite well what the problem was. And as you
assumed I was making a noobish mistake and sent a scathing response to
my problem, I also assumed you were an ass, and needed some kind of
clarification.

> Anyways, you are running an infinite loop and I don't quite see how this
> is exiting:

YES, this is the original question. Why is it exiting. To which you gave
me a whole set of unrequested answers that weren't even on the topic of
my post.

> while (1) 
> {
> if ()
> else
> }
> 
> But, hey, more power to you if you've gotten to the level where you
> don't understand why people who don't understand some esoteric function
> are such muppets.

If you don't understand the function, then why are you posting answers
as though you do? Someone asks me about quantum physics, I don't pretend
to know and confuse the whole issue.

> 
> BTW: If you insist on keeping up with the flamethrowers kindly e-mail me
> off list so as not to bother others on the listserv.

Yes, if you reply I'll be sure to take the next one off list, but since
you made this public, I'm sure readers would love to see the backdraft.
The above statement is actually an underhanded attempt to get the last
public word while preventing me from a public response. If you were so
keen to have it off the list, then this email I'm responding to, should
have been off-list itself.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
On Sat, Sep 20, 2003 at 02:14:54AM -0400, Robert Cummings wrote:
: On Sat, 2003-09-20 at 01:53, Dan Anderson wrote:
: >
: > I find your responses to my e-mails quite humorous.  Upon review --
: > aside from a single WTF -- I don't think I was condescending in any way
: > shape or form.  I was just trying to offer help.
: 
: The particular shape of your help was non newbie friendly. I think that,
: combined with your incorrect assessments made it all the more annoying.
: And yes, "WTF" and "you really need to read the documentation" played a
: key part also since they were quite condescending, and inappropriate
: given your incorrect answers and knowledge of functionality.
[...snips snipped...]

Can't we just get along and bash M$ ?  Or VeriSign ?  :-)

--- End Message ---
--- Begin Message --- File a bug report. stream_set_blocking() started to work for files only since version 4.3, so it is likely full of bugs. Actualy, using cli php 4.3.2 I got this results some weird results. Your version run infinitely but changing echo 'Fooo!'."\n"; to echo 'Fooo!'; (removing newline) resulted in the same behavior as you experienced. fread did not return false even if no key was pressed, only empty string but this might be correct, i don't know. Both fgetc and fgets did return false.

Robert Cummings wrote:

On Sat, 2003-09-20 at 02:02, Curt Zirzow wrote:

hmm.. on second thought...

* Thus wrote Robert Cummings ([EMAIL PROTECTED]):

[...]
       if( ($char = fread( $stdin, 1 )) !== false )

How are you calling this script? I'm not sure how cgi will handle fread <stdin>

With a traditional CGI script <stdin> is what is read on POST data
from a form, and php takes care of this.

That is where my confusion is now.


I'm calling it as "php -qC foo.php". The fread() should work since it
works on input when I don't have stdin in non-blocking mode. Perhaps
it's a bug. I took a look at the doc on streams again, and it uses
php://input as the POST stream. Maybe it's a bug.

Cheers,
Rob.

--- End Message ---
--- Begin Message ---
On Saturday 20 September 2003 10:57, John W. Holmes wrote:

[snip]

>  From my experience, it will work that way. I don't know if it's that
> way for every version or not, though.

manual > Migrating from PHP/FI 2 to PHP 3

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Flirting is the gentle art of making a man feel pleased with himself.
                -- Helen Rowland
*/

--- End Message ---
--- Begin Message ---
* Thus wrote Jason Wong ([EMAIL PROTECTED]):
> On Saturday 20 September 2003 10:57, John W. Holmes wrote:
> 
> [snip]
> 
> >  From my experience, it will work that way. I don't know if it's that
> > way for every version or not, though.
> 
> manual > Migrating from PHP/FI 2 to PHP 3

heh... i havn't seen a PHP/FI reference in a long while, thanks for
reminding us how far php has come along today :)


cheers.

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
On Fri, Sep 19, 2003 at 09:14:57PM -0400, Stevie D Peele wrote:
: 
: How can I clear all cookies that have been previously set?
: 
: I want this in an if statement so something like
: 
: if ($value == $blue){
: clear all cookies;
: setcookie("name",time()+3600);
: }

Walk through your $_COOKIE array and expire each one:

        if ($value == $blue)
        {
                foreach ($_COOKIE as $name => $value)
                {
                        setcookie($_COOKIE["$name"], "", time()-3600);
                }
        }

But I don't know what might happen if you use setcookie() to expire a
cookie and then use setcookie() later on to set the same cookie.

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



We have published the results of the Enterprise PHP research on our website.



See the link to InterAKT and Zend survey, together with lots of insightful
comments, here:

http://developers.slashdot.org/article.pl?sid=03/09/19/2133204&mode=thread&tid=126&tid=169





We would like to get a link to our survey from www.php.net - There is a link
to the Zend Survey, and our is a complementary one.



Whom should we contact? We've tried before and we've never been successful
:)



                Alexandru


-- 
Alexandru COSTIN
Chief Operating Officer
http://www.interakt.ro/
+4021 312 5312

--- End Message ---
--- Begin Message ---
Hello,
We have published the results of the Enterprise PHP research on our website.

See the link to InterAKT and Zend survey, together with lots of insightful
comments, here:
http://developers.slashdot.org/article.pl?sid=03/09/19/2133204

We would like to get a link to our survey from www.php.net - There is a link
to the Zend Survey, and our is a complementary one.

        Alexandru

--
Alexandru COSTIN
Chief Operating Officer
http://www.interakt.ro/
+4021 312 5312

--- End Message ---
--- Begin Message ---
Am Don, 2003-09-18 um 20.36 schrieb Mike Zornek:
> I've created a class called university, it has a constructor which can
> accept an id. If the id is sent during construction the constructor will
> connect to a MySQL db to set all of the objects member variables to the
> MySQl counterparts.
> 
> I'd like to include some error notification so if I send it an id and let's
> say that record doesn't exist in the db I get some notification and can
> write a message out to log (or screen). But what is the best way to do this?
> Any recommendations? Tutorials? URLs?

Maybe you'd like to have a look at PEAR error-handling.

http://pear.php.net/manual/en/core.pear.php


--
Cheers!
 Marco

--- End Message ---
--- Begin Message ---
I've got an error when i try to access www.php.net, are there any
problems?

Paul

GnuPG Key http://sgi.rdscv.ro/~paulm/paulm.PGP

--- End Message ---
--- Begin Message ---
Yonis Rouma wrote:
 Hi I am Daniel H R U
 I am new in PhP and I download Apache2triad 1.1.6 and I install it but when I am 
trying to run apache2triad in my computer it give this Message:  
 "PHP Warning:  Unknown(): Unable to load dynamic library 
'c:\apache2\php\extensions\php_fdf.dll' - A device attached to the system is not 
functioning.
 
 please I want any help to solve my problem quickly. 
 
 Thank you


--- End Message ---
--- Begin Message ---
Hello, I have an intresting problem: I want to let users upload sourcecode
and then compile it using my cygwin gcc... But one thing at a time... I
can't get that gcc to execute...

shell_exec("gcc temp.c"); # Doesn't work as that will use MinGW
shell_exec("D:\\cygwin\\bin\\gcc.exe temp.c"); /* Gives some error about dll
stuff (procedure not found I think)*/

So my next though was to open "bash.exe --login -I" and fwrite the
commands... But that still tries to use the mingw compiler it seems...Guess
there's some environiment problem... So I figured I could use virtual() to a
cgi script with this as first line:
#!D:/cygwin/bin/perl
and then use the perl open(), with |/cygdrive/d/bin/gcc.exe temp.c as
argument... Seems like it executes the right compiler then, but then I get
millions of errors caused by *.h can't be opened (yes, the source tries to
include them), so I though about passing -B /usr/include to it... But those
errors still appear... Also, it feels somewhat bad to use virtual() to call
perl scripts, so I was wondering if you ppl have some nice idea on how I
would do it?

Paths:
Cygwin: d:\cygwin
PHP: C:\PHP (4.3.3, zip from php.net, installed as Apache 1.3.28 module)
Apache: D:\Apache (installed using .msi package, as service)
Perl: D:\perl\bin\perl.exe (or D:\cygwin\bin\perl.exe)
Script: D:\www2\compile.php, D:\www2\compiling\compile_cyg.cgi
Sourcecode: D:\www2\compiling\temp.c (yes, only one file yet, that's a later
problem)

pwd returns I'm in the 'compiling' folder, in the php script, I chdir() to
get into that folder...

Can anyone help, please? Security is not a concern, it's private, and it's
for learning purposes mostly... I use winXP home... I can install stuff like
I want, that's not a problem... Thanks in advance!


-- 
// DvDmanDT
MSN: [EMAIL PROTECTED]
Mail: [EMAIL PROTECTED]

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

I have been trying to do this for weeks but i just cant figure this out. I have 
categories that have subcategories and i want to insert them into database. My table 
looks like this: cat_id, parent_id and cat_name.
Let's say i wanna insert a subcategory that is associated with its parent category.
For example

ParentCat 1 
ParentCat 1 > ItsSubCat 1 
ParentCat 1 > ItsSubCat 2
ParentCat 1 > ItsSubCat 3
ParentCat 1 > ItsSubCat 4
ParentCat 2 
ParentCat 2 > ItsSubCat 1 

and so on ... 

I don't know how to create the script that inserts any subcategory(in this case let's 
say ItsSubCat 3) in its parent category.
Please, can someone help me

thanks

--- End Message ---
--- Begin Message ---
> I don't know how to create the script that inserts any 
> subcategory(in this case let's say ItsSubCat 3) in its parent 
> category.
> Please, can someone help me


I'd use the parent category id as a hidden field in the form when adding a
sub category.

Here is a complete script that contains all the code you would need:

http://destiney.com/pub/phplinks_2.1.2.tar.gz



--
Greg Donald
[EMAIL PROTECTED]
615-746-9414 home
615-594-6052 cell

--- End Message ---
--- Begin Message ---
I have been trying to do this for weeks but i just cant figure this out. I have categories that have subcategories and i want to insert them into database. My table looks like this: cat_id, parent_id and cat_name.
Let's say i wanna insert a subcategory that is associated with its parent category.

If I understand your situatoin, I would create two tables: categories (category_id, category_name) subcategories (subcategory_id, category_id, subcategory_name)

Then, in your PHP script, have the user select the category and enter the subcategory name. The SQL INSERT would then be
INSERT INTO subcategories (category_id, subcategory_name) VALUES ($cat_id, '$subcat_name');


Larry
--- End Message ---
--- Begin Message ---
I need the following replace function:
Replace all line breaks to <br> but not if a line break comes after an </h1>
or </h2> or ....  </hx>


Currently I use this preg_replace but it's not good enough for all
situations.

$text = preg_replace("/([^\<][^\/][^h][^1-9].{1})\r\n/","\\1<br  />",$text);


????

Thanks

--- End Message ---
--- Begin Message ---
$arr = array("/([^\<][^\/][^h][^1-6].{1}[^\>])\r\n/",
             "/([^\<][^\/][^h][^1-6].{1}[^\>])\r/",
             "/([^\<][^\/][^h][^1-6].{1}[^\>])\n/",
             );

$text = preg_replace($arr,"\\1<br  />",$text);

you might try this and see how well it works.

Jim Lucas


----- Original Message ----- 
From: "Armand Turpel" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, September 20, 2003 8:21 AM
Subject: [PHP] preg_replace question


> I need the following replace function:
> Replace all line breaks to <br> but not if a line break comes after an
</h1>
> or </h2> or ....  </hx>
>
>
> Currently I use this preg_replace but it's not good enough for all
> situations.
>
> $text = preg_replace("/([^\<][^\/][^h][^1-9].{1})\r\n/","\\1<br
/>",$text);
>
>
> ????
>
> Thanks
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Hi Jim ,
The problem with your proposition is that the preg_replace do not replace
</h1>\r\n  to  </h1><br /> 
thats good,
but also not this:
testh4>\r\n

and thats not what I expect from.


atur






----- Original Message ----- 
From: "Jim Lucas" <[EMAIL PROTECTED]>
To: "Armand Turpel" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Saturday, September 20, 2003 5:37 PM
Subject: Re: [PHP] preg_replace question


> $arr = array("/([^\<][^\/][^h][^1-6].{1}[^\>])\r\n/",
>              "/([^\<][^\/][^h][^1-6].{1}[^\>])\r/",
>              "/([^\<][^\/][^h][^1-6].{1}[^\>])\n/",
>              );
> 
> $text = preg_replace($arr,"\\1<br  />",$text);
> 
> you might try this and see how well it works.
> 
> Jim Lucas
> 
> 
> ----- Original Message ----- 
> From: "Armand Turpel" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Saturday, September 20, 2003 8:21 AM
> Subject: [PHP] preg_replace question
> 
> 
> > I need the following replace function:
> > Replace all line breaks to <br> but not if a line break comes after an
> </h1>
> > or </h2> or ....  </hx>
> >
> >
> > Currently I use this preg_replace but it's not good enough for all
> > situations.
> >
> > $text = preg_replace("/([^\<][^\/][^h][^1-9].{1})\r\n/","\\1<br
> />",$text);
> >
> >
> > ????
> >
> > Thanks
> >
> > -- 
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> 
> 
>

--- End Message ---
--- Begin Message ---
Hey all.

I'm running a script from the command-line php interpreter as follows:
(thanks to D. Souza for lead)

$text = `usr/local/bin/php /path/to/my/php/page.php`;

within the read file I want to enable sessions, so I session_start() at the
top of the page:

<?
session_start();
?>
<?
    code to execute here.......
?>

Regardless of how I mess around with placement of session_start(), I get a
"Headers already sent".

Why? Nothing has been output to the browser within the read file!
Furthermore, if I create a test page with just:

<?$text = `usr/local/bin/php /path/to/my/php/page.php`;?>

Still receive "Headers already sent".

My eyes are completely fried -- anyone feel like saving my vision?

--Noah

--- End Message ---

Reply via email to