|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general Digest 29 Apr 2006 11:26:53 -0000 Issue 4099
php-general-digest-help
lists.php.net
Date: Sat Apr 29 2006 - 06:26:53 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 29 Apr 2006 11:26:53 -0000 Issue 4099
Topics (messages 235045 through 235090):
Re: PHP Standard style of writing your code
235045 by: Chris W. Parker
235049 by: Robert Cummings
235056 by: Rafael
235058 by: Paul Novitski
235061 by: Robert Cummings
235062 by: Robert Cummings
235067 by: Rafael
235068 by: Richard Lynch
235069 by: Richard Lynch
Re: Multi-threaded port listener
235046 by: Edwin Barrios
235071 by: Richard Lynch
Possible?
235047 by: René Fournier
235050 by: René Fournier
235051 by: John Hicks
235053 by: Warren Vail
235063 by: Richard Lynch
235065 by: Richard Lynch
Re: strange php url (CORRECTION)
235048 by: Kevin Kinsey
Re: display_errors off and custom error pages
235052 by: chris smith
235072 by: Richard Lynch
235090 by: Jochem Maas
Re: RegExp for preg_split()
235054 by: John Hicks
235064 by: Rafael
235077 by: Richard Lynch
Re: we are looking for experienced php programmers full timefreelance...
235055 by: Nicolas Verhaeghe
235059 by: chris smith
Re: Help!
235057 by: Martin Alterisio
235060 by: chris smith
235066 by: Dave Goodchild
235074 by: Richard Lynch
235076 by: Dave Goodchild
235078 by: chris smith
235079 by: Richard Lynch
235080 by: Richard Lynch
235081 by: Richard Lynch
235082 by: Dave Goodchild
Re: GD text proc via php OK for local strings, but NOT for SESSION-passed strings. why?
235070 by: Richard Lynch
Re: Beginner's php/mysql connection probs
235073 by: Richard Lynch
Re: getting current page url
235075 by: Richard Lynch
Re: Includes and paths confusion
235083 by: Richard Lynch
IPN error
235084 by: suresh kumar
235088 by: Richard Lynch
Re: forms and dynamic creation and unique field names
235085 by: Richard Lynch
Re: Uploading pic
235086 by: Richard Lynch
Re: error message
235087 by: Richard Lynch
Re: php <-> js (was Javascript Navigation)
235089 by: Richard Lynch
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Richard Lynch <mailto:ceo
l-i-e.com>
on Monday, April 24, 2006 11:50 PM said:
> So no matter what was actually typed, *I* would see:
>
> function foo ($x) {
> //body
> }
>
> but some heretic who doesn't know any better would see:
> function foo($x)
> {
> //body
> }
>
> Now *THAT* would be a feature worth paying for in an IDE! :-)
Setting aside the fact that you're completely wrong about your preference... ;)
What, in your mind, is the advantage to putting the opening brace on the same line as the function call, logic statement, etc.? (Btw, this is a serious question!)
Chris.
p.s. Yes I'm still alive. Just haven't been able to work on any web related stuff for a long time here are work. :( The downside of being the IT department.
attached mail follows:
On Fri, 2006-04-28 at 18:18, Chris W. Parker wrote:
> Richard Lynch <mailto:ceo
l-i-e.com>
> on Monday, April 24, 2006 11:50 PM said:
>
> > So no matter what was actually typed, *I* would see:
> >
> > function foo ($x) {
> > //body
> > }
> >
> > but some heretic who doesn't know any better would see:
> > function foo($x)
> > {
> > //body
> > }
> >
> > Now *THAT* would be a feature worth paying for in an IDE! :-)
>
> Setting aside the fact that you're completely wrong about your preference... ;)
>
> What, in your mind, is the advantage to putting the opening brace on the
> same line as the function call, logic statement, etc.? (Btw, this is a
> serious question!)
You know what they say...
"Job security through code obscurity!"
And no, I don't know who "they" are :) I'm in the vertically aligned
brace camp. It's just cleaner when the braces line up because you can
pick out the beginning and end of the block easier... doubly so when you
have a long conditional that wraps... KISS baby!
> p.s. Yes I'm still alive. Just haven't been able to work on any web related
> stuff for a long time here are work. :( The downside of being the IT
> department.
Good to see you again! :)
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. |
`------------------------------------------------------------'
attached mail follows:
IMHO, vertical aligned brackets can be messy when nesting
relatively-small blocks (and seems to me like a lot of wasted space)
A couple of facts of my codding style:
- I tend to always use brakets, so I ignore the fact that single
lines/actions can be written without brackets,
- I try not to let lines grow larger than about 100 cols (cannot
be really done with strings and other thingies, and maybe that
should remain in the old 80 cols, but it's too litle space), and
- I use a 4 space indentation, and that alone suffices for making
a block stand clear enough
So, in my case, the code would be something like
function foo( $x ) {
// body...
}
···
$a = foo($b);
Chris W. Parker wrote:
>> So no matter what was actually typed, *I* would see:
>>
>>function foo ($x) {
>> //body
>>}
>>
>>but some heretic who doesn't know any better would see:
>>function foo($x)
>>{
>> //body
>>}
[···]
> Setting aside the fact that you're completely wrong about your
> preference... ;)
>
> What, in your mind, is the advantage to putting the opening brace on
> the same line as the function call, logic statement, etc.? (Btw, this
> is a serious question!)
[···]
P.S. What, in your mind, is the advantage of replying after quoting the
original message and not before? :)
--
Atentamente,
J. Rafael Salazar Magaña
Innox - Innovación Inteligente
Tel: +52 (33) 3615 5348 ext. 205 / 01 800 2-SOFTWARE
http://www.innox.com.mx
attached mail follows:
> IMHO, vertical aligned brackets can be messy when nesting
>relatively-small blocks (and seems to me like a lot of wasted space)
I'm struggling to get my head around this concept of 'wasted space'
with regard to software code. What is it that's getting wasted,
exactly? If we printed our programs on paper it would be wasted
trees (page-space) but I almost never do this and I don't know anyone
who does except banks. It could be seen as a waste of disk space,
but only at the rate of a few bytes per code block, carriage return
plus perhaps a couple of tabs. What we must be talking about here is
a waste of visual space. How does visual space get wasted? Isn't it
possible to waste something only if it's in finite supply? I guess
it's being wasted if it's something valuable that's not being
used. However, the urge to add whitespace to spread things apart is
done with the intent of making code easier to read, so that seems
like a use, not a waste.
OK, OK, I'll stop. Think I'll go out and get wasted~
P.
attached mail follows:
On Sat, 2006-04-29 at 01:38, Rafael wrote:
> IMHO, vertical aligned brackets can be messy when nesting
Explain messy!?
> relatively-small blocks (and seems to me like a lot of wasted space)
Did you just say wasted space? I mean it's not like 99.9% (pulled from
the dark recesses of my behind) of code gets printed. So that leaves
wasted space on what? My 500 gigs of HD space? You are kidding right?!
> A couple of facts of my codding style:
beat it over a head, gut it, cook over an open fire? ;)
> - I tend to always use brakets, so I ignore the fact that single
Are they tools to help you slow down?
> lines/actions can be written without brackets,
I do so also, it's just good maintenance style since adding code to the
conditional doesn't require adding the braces in the future.
> - I try not to let lines grow larger than about 100 cols (cannot
> be really done with strings and other thingies, and maybe that
> should remain in the old 80 cols, but it's too litle space), and
I still keep my lines at 80... on rare cases 81 :)
> - I use a 4 space indentation, and that alone suffices for making
> a block stand clear enough
Ditto... but those vertically aligned braces just make it eve clearer.
> So, in my case, the code would be something like
> function foo( $x ) {
> // body...
> }
> ···
> $a = foo($b);
Yeah, you're in the lynch camp... yeeeeeeeeeeuck ;)
Cheers,
Rob.
> Chris W. Parker wrote:
> >> So no matter what was actually typed, *I* would see:
> >>
> >>function foo ($x) {
> >> //body
> >>}
> >>
> >>but some heretic who doesn't know any better would see:
> >>function foo($x)
> >>{
> >> //body
> >>}
> [···]
> > Setting aside the fact that you're completely wrong about your
> > preference... ;)
> >
> > What, in your mind, is the advantage to putting the opening brace on
> > the same line as the function call, logic statement, etc.? (Btw, this
> > is a serious question!)
> [···]
> P.S. What, in your mind, is the advantage of replying after quoting the
> original message and not before? :)
Standard netiquette. Only top post when fighting the power :B
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. |
`------------------------------------------------------------'
attached mail follows:
On Sat, 2006-04-29 at 02:08, Paul Novitski wrote:
> > IMHO, vertical aligned brackets can be messy when nesting
> >relatively-small blocks (and seems to me like a lot of wasted space)
>
> I'm struggling to get my head around this concept of 'wasted space'
> with regard to software code. What is it that's getting wasted,
> exactly? If we printed our programs on paper it would be wasted
> trees (page-space) but I almost never do this and I don't know anyone
> who does except banks. It could be seen as a waste of disk space,
> but only at the rate of a few bytes per code block, carriage return
> plus perhaps a couple of tabs. What we must be talking about here is
> a waste of visual space. How does visual space get wasted? Isn't it
> possible to waste something only if it's in finite supply? I guess
> it's being wasted if it's something valuable that's not being
> used. However, the urge to add whitespace to spread things apart is
> done with the intent of making code easier to read, so that seems
> like a use, not a waste.
>
> OK, OK, I'll stop. Think I'll go out and get wasted~
Drink with friends... that way you have someone to brace you when you're
fall down drunk.
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. |
`------------------------------------------------------------'
attached mail follows:
It's kind of ironic that you didn't split that big chunk of text into
paragraphs, don't you think? ;)
Anyway, yes, I was referring to visual space, we all know that is more
clear the more you can see the code, that's why we don't let rows go
insinely long (well, wide actually), and that also applies for the
"vertical viewport" (rows also, not only columns) That's why *I* find
it a waste of (vertical) space.
But, as we all know also, coding style is just that, a style, yet
another matter of taste --of course, there are some basics that should
always be present for the sake of clarity (such as indentation,
comments, and an empty line here and there as logic-separator), or
that's what I think, anyway --let's not discuss about this, wi'l ya?
Paul Novitski wrote:
>> IMHO, vertical aligned brackets can be messy when nesting
>> relatively-small blocks (and seems to me like a lot of wasted space)
>
> I'm struggling to get my head around this concept of 'wasted space' with
> regard to software code. What is it that's getting wasted, exactly? If
> we printed our programs on paper it would be wasted trees (page-space)
> but I almost never do this and I don't know anyone who does except
> banks. It could be seen as a waste of disk space, but only at the rate
> of a few bytes per code block, carriage return plus perhaps a couple of
> tabs. What we must be talking about here is a waste of visual space.
> How does visual space get wasted? Isn't it possible to waste something
> only if it's in finite supply? I guess it's being wasted if it's
> something valuable that's not being used. However, the urge to add
> whitespace to spread things apart is done with the intent of making code
> easier to read, so that seems like a use, not a waste.
>
> OK, OK, I'll stop. Think I'll go out and get wasted~
>
> P.
--
Atentamente,
J. Rafael Salazar Magaña
Innox - Innovación Inteligente
Tel: +52 (33) 3615 5348 ext. 205 / 01 800 2-SOFTWARE
http://www.innox.com.mx
attached mail follows:
On Fri, April 28, 2006 5:18 pm, Chris W. Parker wrote:
> Richard Lynch <mailto:ceo
l-i-e.com>
> on Monday, April 24, 2006 11:50 PM said:
>
>> So no matter what was actually typed, *I* would see:
>>
>> function foo ($x) {
>> //body
>> }
>>
>> but some heretic who doesn't know any better would see:
>> function foo($x)
>> {
>> //body
>> }
>>
>> Now *THAT* would be a feature worth paying for in an IDE! :-)
>
> Setting aside the fact that you're completely wrong about your
> preference... ;)
>
> What, in your mind, is the advantage to putting the opening brace on
> the same line as the function call, logic statement, etc.? (Btw, this
> is a serious question!)
Okay, but let's do keep this fairly serious, and let's NOT let it
devolve into the usual religious flame-war this topic gets to...
Since it IS a religious question, I'm not super-interested in
discussing it with too many go-rounds...
The reasons I chose the brace-on-same-line style, way long time ago:
#1.
Screen real estate and lines of code are fairly precious to me.
Lines wasted for { on a line by itself is just, err, wasteful. :-)
Obviously, some consider that { line by itself useful, but I don't
consider the cost/benefit ratio sufficient to warrant the expense.
#2.
The indentation of the following lines is more than sufficient, with
practice, for the eye to follow the program flow.
An extra line, almost blank, does not make it any easier to "see" the
code flow.
To see this, you have to practice reading both styles in equal
measure, however, and most programmers don't really do that.
#3.
Obviously, whatever one gets used to typing for oneself is the EASIEST
to read.
But if you end up reading a lot of other people's code anyway, you
pretty much have to live with all the different styles.
I'd rather use the more compact style, since I have to be able to read
all of them anyway.
#4.
To me, the brace and what is "going on" in the program at that
juncture are inseparable from the logic that makes the brace
necessary.
I'm not sure how to express this well, but the best I can do is:
The logic and its brace are one and the same, not separate things, and
they should be on the same line because they are one and the same.
The code block body is indented, because it is encompassed by the
program logic, in the sense that the body is either executed or not
based on the logic.
The braces are not something to be executed or not executed, but are
simply delimiters for the code block body. They are more a part of
the logical structure of the program logic, then they are a part of
the body, because they delimit the structure, rather than get executed
(or not).
#5.
If you print it out on that old-school 3-line alternating green-bar
fan-fold paper, and you hang it up across the room, it's much prettier
as ASCII art with the braces on the same line.
The preceding sentence is obviously a very subjective statement.
But I'm totally serious here -- I made this decision in college circa
1981, and I wrote the same long program both ways, and hung the two
versions up on the wall side-by-side, and I liked the one with { on
the same lines better.
I even solicited my non-programmer roommates' opinions, and they also
preferred the braces on the same line as ASCII art.
The extra practically blank lines version was not as pretty as ASCII
art from a distance.
Note that I (and obviously my roommtes) had no pre-conceived
preference before this ASCII art gallery test.
I daresay an experienced programmer is going to pick the style they
prefer as "prettier."
Though it would be an interesting experiment for some psychology
student to A/B compare with programmers, non-programmers, experienced
programmers, etc...
Well, there it is, fwiw.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On Sat, April 29, 2006 1:08 am, Paul Novitski wrote:
>> IMHO, vertical aligned brackets can be messy when nesting
>>relatively-small blocks (and seems to me like a lot of wasted space)
>
> I'm struggling to get my head around this concept of 'wasted space'
> with regard to software code. What is it that's getting wasted,
> exactly? If we printed our programs on paper it would be wasted
> trees (page-space) but I almost never do this and I don't know anyone
> who does except banks. It could be seen as a waste of disk space,
> but only at the rate of a few bytes per code block, carriage return
> plus perhaps a couple of tabs. What we must be talking about here is
> a waste of visual space. How does visual space get wasted? Isn't it
> possible to waste something only if it's in finite supply? I guess
> it's being wasted if it's something valuable that's not being
> used. However, the urge to add whitespace to spread things apart is
> done with the intent of making code easier to read, so that seems
> like a use, not a waste.
If you tend to have a fair amount of code with small blocks, and you
can only see X lines on the screen at once, then the wasted space is
in how much of the program logic you can view in one screenful.
I'll also respond to another poster:
I personally have no less/more ease in aligning } with a logic
statement or with another {, *IF* the code is indented properly.
In other words, the vertical alignment is more a function of the
indentation, to me, then of a specific character I have to pick out.
If the code isn't indented properly, well, then, the alignment of
whatever you do vertically doesn't matter much, eh?
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Hi.
If you want a separate script execution, you can use inetd o xinetd to
listen for you that port.
When inetd got a connection execute your php script, one execution by
connection.
I think that it is more usefull to create your own responser server with
php using forks !. But using inetd has the advantage that you can use
tcpwrappers.
On 4/28/06, René Fournier <m5
renefournier.com> wrote:
>
> Anyone find any good tutorials, code samples, etc. on such a thing?
> Basically, I want to write server (in PHP) that listeners on a
> particular port, and spins off a thread/process (essentially, execute
> a separate script) for each incoming connection. There won't be a lot
> of data to process, but there will be many simultaneous connections—
> upwards of 1000s of connections (each spun off as seperate threads).
>
> ...Rene
>
>
>
>
>
attached mail follows:
On Fri, April 28, 2006 3:23 pm, René Fournier wrote:
> Anyone find any good tutorials, code samples, etc. on such a thing?
> Basically, I want to write server (in PHP) that listeners on a
> particular port, and spins off a thread/process (essentially, execute
> a separate script) for each incoming connection. There won't be a lot
> of data to process, but there will be many simultaneous connections—
> upwards of 1000s of connections (each spun off as seperate threads).
http://php.net/fork
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Simple problem: Many client apps need to send data to a server.
By default each client will open a persistent TCP socket connection
to a common IP address:port (10.10.10.10:1234) and write to it (which
the server will save/log, etc.).
My question is, what should be ready to listen at the IP:port? I was
thinking of writing a PHP command-line socket server that listens at
that port. But there will be a potentially huge number of clients
connecting simultaneously (1000s), not transmitting a lot of data per
se, but a lot of connections... Anyway, instead I thought writing a
simple PHP script—say, listener.php—that gets executed by the web
server and enters a socket_read loop until the client terminates the
connection (set_time_limit(0)).
Does this sound like a good way to do it? This way, Apache handles
all the connections, and PHP is instantiated each time, but without
having to fork processes, etc, and without having to do PHP CLI.
Anyway, I've started looking at this, but I'm not quite sure if it's
even possible. I mean, can "something" send a request to Apache, and
continue to write data along that TCP socket? Normally, HTTP requests
include GET or POST for such data, but this is not a a web browser
that's opening the connection.
Hope I'm somewhat clear. Just struggling through some options
here.... Anyway, thanks in advance for any suggestions.
...Rene
attached mail follows:
>> Anyway, I've started looking at this, but I'm not quite sure if
>> it's even possible. I mean, can "something" send a request to
>> Apache, and continue to write data along that TCP socket?
>> Normally, HTTP requests include GET or POST for such data, but
>> this is not a a web browser that's opening the connection.
>> Hope I'm somewhat clear. Just struggling through some options
>> here.... Anyway, thanks in advance for any suggestions.
>> ...Rene
>
> > each client will open a persistent TCP socket connection to a
> > common IP address:port (10.10.10.10:1234)
>
> (If you want simultaneous connections, each TCP connection will be
> to a different port.)
Well, not if the client (actually, it's a pre-programmed physical
device) is set to always open a socket connection to
10.10.10.10:1234... right?
> But rather than write a client and a server application from
> scratch, why not just use HTTP POSTs?
I'm not writing the client, I just need to make a server that can
accept numerous simultaneous incoming socket connections, and
maintain them.
Maybe stream_select() as someone suggested? I suppose my question
would be, can a single PHP socket server script, executed from the
command-line, maintain 1000s of concurrent connections (there is not
a lot of data incoming, btw)?
...Rene
attached mail follows:
René Fournier wrote:
> Simple problem: Many client apps need to send data to a server.
>
> By default each client will open a persistent TCP socket connection to a
> common IP address:port (10.10.10.10:1234) and write to it (which the
> server will save/log, etc.).
>
> My question is, what should be ready to listen at the IP:port? I was
> thinking of writing a PHP command-line socket server that listens at
> that port. But there will be a potentially huge number of clients
> connecting simultaneously (1000s), not transmitting a lot of data per
> se, but a lot of connections... Anyway, instead I thought writing a
> simple PHP script—say, listener.php—that gets executed by the web server
> and enters a socket_read loop until the client terminates the connection
> (set_time_limit(0)).
>
> Does this sound like a good way to do it? This way, Apache handles all
> the connections, and PHP is instantiated each time, but without having
> to fork processes, etc, and without having to do PHP CLI.
>
> Anyway, I've started looking at this, but I'm not quite sure if it's
> even possible. I mean, can "something" send a request to Apache, and
> continue to write data along that TCP socket? Normally, HTTP requests
> include GET or POST for such data, but this is not a a web browser
> that's opening the connection.
>
> Hope I'm somewhat clear. Just struggling through some options here....
> Anyway, thanks in advance for any suggestions.
>
> ...Rene
> each client will open a persistent TCP socket connection to a
> common IP address:port (10.10.10.10:1234)
(If you want simultaneous connections, each TCP connection will be to a
different port.)
But rather than write a client and a server application from scratch,
why not just use HTTP POSTs?
"Keep It Simple, Stewart."
--John
attached mail follows:
Have you considered implementing a http service?
http://www.php.net/manual/en/ref.wddx.php
I believe this will relieve you of all the connection management stuff and
use the apache server to handle thread management. All your clients would
perform something very similar to a post with their information, and each
server thread does it's insert. If you design your tables with an auto
increment primary key, you should avoid problems with multiple concurrent
inserts coliding on the same table.
I found the following information helpful in evaluating the use of wddx;
http://www.openwddx.org/faq/
Good luck,
Warren Vail
-----Original Message-----
From: René Fournier [mailto:m5
renefournier.com]
Sent: Friday, April 28, 2006 4:50 PM
To: PHP-General; John Hicks
Subject: Re: [PHP] Possible?
>> Anyway, I've started looking at this, but I'm not quite sure if it's
>> even possible. I mean, can "something" send a request to Apache, and
>> continue to write data along that TCP socket?
>> Normally, HTTP requests include GET or POST for such data, but this
>> is not a a web browser that's opening the connection.
>> Hope I'm somewhat clear. Just struggling through some options
>> here.... Anyway, thanks in advance for any suggestions.
>> ...Rene
>
> > each client will open a persistent TCP socket connection to a common
> > IP address:port (10.10.10.10:1234)
>
> (If you want simultaneous connections, each TCP connection will be to
> a different port.)
Well, not if the client (actually, it's a pre-programmed physical
device) is set to always open a socket connection to 10.10.10.10:1234...
right?
> But rather than write a client and a server application from scratch,
> why not just use HTTP POSTs?
I'm not writing the client, I just need to make a server that can accept
numerous simultaneous incoming socket connections, and maintain them.
Maybe stream_select() as someone suggested? I suppose my question would be,
can a single PHP socket server script, executed from the command-line,
maintain 1000s of concurrent connections (there is not a lot of data
incoming, btw)?
...Rene
attached mail follows:
On Fri, April 28, 2006 6:13 pm, René Fournier wrote:
> Simple problem: Many client apps need to send data to a server.
>
> By default each client will open a persistent TCP socket connection
> to a common IP address:port (10.10.10.10:1234) and write to it (which
> the server will save/log, etc.).
>
> My question is, what should be ready to listen at the IP:port? I was
> thinking of writing a PHP command-line socket server that listens at
> that port. But there will be a potentially huge number of clients
> connecting simultaneously (1000s), not transmitting a lot of data per
> se, but a lot of connections...
Bring it on.
[bunny]
The PHP script you write just has to NOT QUIT, but keep on going and
going and going and...
[/bunny]
> Anyway, instead I thought writing a
> simple PHP script—say, listener.php—that gets executed by the web
> server and enters a socket_read loop until the client terminates the
> connection (set_time_limit(0)).
Don't tie up your HTTP connections for this.
> Does this sound like a good way to do it? This way, Apache handles
> all the connections, and PHP is instantiated each time, but without
> having to fork processes, etc, and without having to do PHP CLI.
You're making life WAY too complicated for yourself!
> Anyway, I've started looking at this, but I'm not quite sure if it's
> even possible. I mean, can "something" send a request to Apache, and
> continue to write data along that TCP socket? Normally, HTTP requests
> include GET or POST for such data, but this is not a a web browser
> that's opening the connection.
You probably can't do this, and even if you could, you don't WANT to
do this!
> Hope I'm somewhat clear. Just struggling through some options
> here.... Anyway, thanks in advance for any suggestions.
You should try the simple solution first:
http://php.net/sockets
The "talkback" server example there is a good starter kit.
You then just need to have it be able to handle the connections and
put the data somewhere -- A MySQL ISAM table is probably the easiest
and most likely to handle the volume you want, at a guess...
If THAT is not fast enough, then your next move is not to try and hack
Apache to get a "pool" going, but to find something LIKE the Apache
dispatcher to wrap around your server.
Or, possibly, consider setting up a "pool" of hardware to handle the
connections.
But first, make sure that the straightforward approach is "too slow"
before you get yourself all bent out of shape trying to solve a
problem that doesn't exist. :-)
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On Fri, April 28, 2006 6:49 pm, René Fournier wrote:
> I suppose my question
> would be, can a single PHP socket server script, executed from the
> command-line, maintain 1000s of concurrent connections (there is not
> a lot of data incoming, btw)?
I suppose my answer boils down to:
You'll never know until you try, on YOUR hardware with YOUR software.
I suspect that if ALL your server does is slam the data into MySQL or
fwrite() to an opened (once at start) file, it will be fine -- or at
least in the ballpark enough that you can explore measures to make it
faster rather than build something super complex. That's just a WILD
GUESS. Only a test on your hardware will tell you.
The good thing is, a test script from the example in the manual should
take you, what, an hour to write, a day to debug and make sure it
works with multiple clients, and another day or two to stress test and
see if it can handle the load?
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Kevin Kinsey wrote:
> Pretty good thoughts, there. Some years ago, Tim Perdue
> (of PHPBuilder and SourceForge fame) had a popular
> article on "Search Engine Friendly URL's" (or some such),
> in which he described use of the Apache ForceLocal
> directive to make a site just One Big Script, parsing
> the slashed portions of the query string as variables
> (instead of GET, a la "?section=man&term=foo") so that
> the browser appears to be accessing documents in subfolders,
> but it's really just telling the server to grab a page with certain
> values defined in the URI.
>
> It sure looks like a possibility of this or similar magic in
> this case. Of course, I could be way off my tree...
And it appears I was at least *slightly* off my tree. In looking for
more info on this, my post (archived in 2 places), was the only
reference to a "ForceLocal" directive in Apache that Google could find ;-)
I meant "ForceType", and here's how it works in httpd.conf:
<VirtualHost *>
ServerName test.foo.com
DocumentRoot /var/www/data/footest
ServerAdmin root
localhost
<Location /manual>
ForceType application/x-httpd-php
</Location>
</VirtualHost>
Now, you write "manual" in PHP, (no file extension), and anything
directed to "manual" is parsed by said script.
Since I used the wrong terminology, I may have distracted any *real*
gurus from recognizing what I was talking about. Sorry for any confusion.
Kevin Kinsey
--
It's hard to think of you as the end
result of millions of years of evolution.
attached mail follows:
On 4/29/06, IG <php
selectperformers.com> wrote:
> I've spent the last couple of hours trying to work this out to no avail.
>
> I have recently moved over to a managed dedi server and no can ask my
> host to change my php.ini.
>
> I have found out that the 'display_errors' in the php.ini is set to off
> and error file logging is off.
>
> I would like to be able log to file which is easy to do from the ini
> file but also to show a custom error page if there is an error on one of
> the pages.
>
> I thought I would be able to use a custom error handler such as -
>
> ob_start();
> // custom error handler
> function e($type, $msg, $file, $line) {
> blah blah
> ob_end_clean();
>
> // display error page
> exit();
> }
>
> set_error_handler("e");
>
>
>
> But all I get is a blank page. Does having display_errors off mean that
> I can't use a custom error handler? I have also tried adding
> *set_ini*('*display_errors*','1') but this keeps giving me a blank page.
Sounds like a parse error (using the code above will give you that).
Try it in a htaccess file:
php_flag display_errors 1
(I think).
You can't use ini_set because a parse error breaks the whole script
and it's not executed, so you need to change this value before the
script.
--
Postgresql & php tutorials
http://www.designmagick.com/
attached mail follows:
On Fri, April 28, 2006 11:55 am, IG wrote:
> I have recently moved over to a managed dedi server and no can ask my
> host to change my php.ini.
>
> I have found out that the 'display_errors' in the php.ini is set to
> off
> and error file logging is off.
Do they have .htaccess turned on?
Because you can set all this stuff in an .htaccess file...
> I would like to be able log to file which is easy to do from the ini
> file but also to show a custom error page if there is an error on one
> of
> the pages.
>
> I thought I would be able to use a custom error handler such as -
>
> ob_start();
You do not need, nor even want probably, ob_start() just to be able to
use a custom error handler.
It doesn't HURT, mind you, but it's not needed at all.
> // custom error handler
> function e($type, $msg, $file, $line) {
> blah blah
> ob_end_clean();
>
> // display error page
> exit();
> }
>
> set_error_handler("e");
>
> But all I get is a blank page.
Well, unless your "blah blah" section outputs something, all you COULD
get is a blank page.
> Does having display_errors off mean
> that
> I can't use a custom error handler?
No, not at all.
> I have also tried adding
> *set_ini*('*display_errors*','1') but this keeps giving me a blank
> page.
What are all those * characters in there? Get rid of them.
> Can someone tell me the best (and most secure way) of having custom
> error pages in php. Ideally I would like it all set from a central
> place
> so that i only need to change one file for all the websites on our
> server.
.htaccess, if it is on, will do this, and not require you to remember
to 'include' the error_handler on every script.
> I didn't really want to change display_errors to on as I was
> told this wasn't very secure-
That is correct.
It is too likely to expose too much information to Bad Guys.
> i don't want error messages on any of my
> pages, I just want a simple error 500 server error page.
Whoa.
Okay, now we are in a different kettle of fish...
I dunno that you CAN force a "500 server error" from within PHP...
I guess there ought to be a function for that somewhere, but I've
never noticed it...
It would probably be documented or linked from or discussed in the
User Contributed notes at http://php.net/header though, if it does
exist.
Would you settle for a nice HTML output like:
<p class="error">An error has occurred. Please try again later.</p>
Because that's pretty much a no-brainer with the error handler -- But
you have to actually output that.
I think your basic problem right now is the assumption that PHP exit()
with no content output would somehow constitute a 500 server error.
It doesn't.
[shrug]
There's nothing inherently "wrong" with the webserver returning a
totally blank document, really. Well, okay, by strict definitions of
HTML w3c standards, it's not valid HTML.
But it's also not a 500 error either.
As far as Apache is concerned, the document is "fine" and returns a
200. It just happens to be an empty/blank document is all.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
IG wrote:
> I've spent the last couple of hours trying to work this out to no avail.
>
> I have recently moved over to a managed dedi server and no can ask my
> host to change my php.ini.
>
> I have found out that the 'display_errors' in the php.ini is set to off
> and error file logging is off.
>
> I would like to be able log to file which is easy to do from the ini
> file but also to show a custom error page if there is an error on one of
> the pages.
>
> I thought I would be able to use a custom error handler such as -
>
> ob_start();
> // custom error handler
> function e($type, $msg, $file, $line) {
> blah blah
> ob_end_clean();
while (
ob_end_clean());
// and
header('Status: 500 Internal Server Error');
are things you should look at.
also the check the ini setting auto_prepend_file, which can be
set in your apache config so that all vhosts share a common
include file which defines and sets the errorhandler.
also apache has the ability to set a custom handler for 'real'
500 errors. the apache directive is something like:
ErrorDocument 500 /path/to/my/500.php
where the path is a url (or a local path - I think)
>
> // display error page
> exit();
> }
>
> set_error_handler("e");
>
>
>
> But all I get is a blank page. Does having display_errors off mean that
> I can't use a custom error handler? I have also tried adding
> *set_ini*('*display_errors*','1') but this keeps giving me a blank page.
>
> Can someone tell me the best (and most secure way) of having custom
> error pages in php. Ideally I would like it all set from a central place
> so that i only need to change one file for all the websites on our
> server. I didn't really want to change display_errors to on as I was
> told this wasn't very secure- i don't want error messages on any of my
> pages, I just want a simple error 500 server error page.
>
> Many thanks,
>
> Ian
>
attached mail follows:
Weber Sites LTD wrote:
> Hi
>
> I'm looking for the RegExp that will split a search string into search
> keywords.
> while taking " " into account.
>
>>From what I managed to find I can get all of the words into an array but I
> would
> like all of the words inside " " to be in the same array cell.
You want to use preg_match_all, not preg_split:
$String = 'Medaillons, Listels, "custom stuff", "more things", entryway,
accents, showplace';
$MyRegEx = '/"[^"]+"|[^"\s,]+/';
preg_match_all($MyRegEx, $String, $Tokens);
echo '<pre>';
var_dump($Tokens);
produces:
array(1) {
[0]=>
array(7) {
[0]=>
string(10) "Medaillons"
[1]=>
string(7) "Listels"
[2]=>
string(14) ""custom stuff""
[3]=>
string(13) ""more things""
[4]=>
string(8) "entryway"
[5]=>
string(7) "accents"
[6]=>
string(9) "showplace"
}
}
attached mail follows:
Try this (don't pay attention to the name):
/**
*
param string $text
*
return array
*
since Sat Apr 29 01:35:37 CDT 2006
*
author rsalazar
*/
function parse_phrases( $text ) {
$arr_pzas = array();
if ( preg_match_all('/(?(?=["\'])(["\']).+?\\1|\w+)/X',
$text, $arr_pzas) ) {
$arr_pzas = $arr_pzas[0];
}
return $arr_pzas;
} // parse_phrases()
Weber Sites LTD wrote:
> Hi
>
> I'm looking for the RegExp that will split a search string into search
> keywords.
> while taking " " into account.
>
> From what I managed to find I can get all of the words into an array but I
> would
> like all of the words inside " " to be in the same array cell.
--
Atentamente,
J. Rafael Salazar Magaña
Innox - Innovación Inteligente
Tel: +52 (33) 3615 5348 ext. 205 / 01 800 2-SOFTWARE
http://www.innox.com.mx
attached mail follows:
On Fri, April 28, 2006 11:16 am, Weber Sites LTD wrote:
> I'm looking for the RegExp that will split a search string into search
> keywords.
> while taking " " into account.
>
> From what I managed to find I can get all of the words into an array
> but I
> would
> like all of the words inside " " to be in the same array cell.
I'd be pretty surprised if searching for things like:
PHP simple search input quotes
and things like that didn't turn up some solutions...
You might have to search in specific forums rather than a general
Google, but.
Here's one crude solution though:
<?php
$input = 'this is a "test expression" for search input';
//remove duplicate spaces:
$input = preg_replace('/\\s+/', ' ', $input);
//ignore leading/trailing blanks:
$input = trim($input);
$parts = explode('"', $input);
$terms = array();
$in_quotes = false;
foreach($parts as $expression){
$expression = trim($expression); //probably not needed...
if (strlen($expression)){
if (!$in_quotes){
//individual words:
$words = explode(' ', $expression);
$terms = array_merge($terms, $words);
}
else{
//in quotes, so this is a search term:
$terms[] = $expression;
}
}
$in_quotes = !$in_quotes;
}
var_dump($terms);
?>
Note that invalid input such as unbalanced quote marks will mess this
up big-time, probably...
But maybe that's just as well...
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Sumeet wrote:
> we are looking for experienced php/mysql programmers full time
> freelance...
>
> should be at least 1 year experienced, knowing pear libraries and
> having
> worked on several projects.
>
> please contact me at sumeet
prateeksha.com
>
> quote your charges and the time that you will be available. also
> mention
> msn or yahoo ids. skype id is more welcome.
>
$300 / hr
8 hr minimum per day
available 0800 - 0900EST
------------
You want a Beemer?
attached mail follows:
On 4/28/06, Sumeet <mailing
prateeksha.com> wrote:
> we are looking for experienced php/mysql programmers full time freelance...
You could post job details on either elance.com, rentacoder.com or
other similar sites (I'm sure there are tons more)...
--
Postgresql & php tutorials
http://www.designmagick.com/
attached mail follows:
2006/4/28, Barry <barry
flyerheaven.de>:
>
> Martin Alterisio schrieb:
> > 2006/4/28, Dave Goodchild <buddhamagnet
gmail.com>:
> >>
> >> Hi all - I am attempting to solve some maddening behaviour that has me
> >> totally stumped and before I take a blade to my throat I thought I
> would
> >> pick the brains of the group/hive/gang.
> >>
> >> I am working on a viral marketing application that uses multipart
> emails
> >> to
> >> notify entrants of their progress in the 'game'. I have a demo version
> >> which
> >> works fine, and the current rebranded version was also fine until the
> >> client
> >> asked for some changes then POWWWWW!
> >>
> >> I will try and define the issue as simply as I can. I am passing 11
> >> arguments to a function called sendSantaMail (don't ask) and as a
> sanity
> >> check I have called mail() to let me know the values just before they
> are
> >> passed in to the function. I get this result:
> >
> >
> > sendSantaMail???? That's just not a *declarative* way of naming a
> function.
> Do you know what "santa" means? No? so how can you tell it's not
> declarative.
> Santa could be a coded Mailer and that functions uses that specific
> Mailer Deamon called "santa" to send mails.
Yeah you're right, I was thinking the exact same thing a while after I
posted that. Maybe it was a correct name in the context used, but, I still
think "Santa" is a really misleading name for a mailer, and not to mention
that a mass mailer identifying itself as "Santa mailer" in the headers is
asking to be send directly to spam. Anyway, I was wrong.
> Then, 11 arguments???? Errr, passing an associative array with the email
> > parameters wouldn't have been a cleaner and better option?
>
> He just told he passes 11 arguments, never told how he does that.
Well, if somebody tells you a function has 11 arguments what would you
think?
attached mail follows:
On 4/29/06, Dave Goodchild <buddhamagnet
gmail.com> wrote:
> Thanks all. Worst case scenario I can rebuild from the demo as it works
> (really don't want to do that). Was loathe to plaster your screens with
> miles of code but understand it's hard to assit without it.
If you still need help..
http://www.pastebin.com
send us a url with your code and we'll go from there.
--
Postgresql & php tutorials
http://www.designmagick.com/
attached mail follows:
Misleading to who? I own the app and am the only person who will ever use
it. Rather anal.
On 29/04/06, Martin Alterisio <malterisio777
gmail.com> wrote:
>
> 2006/4/28, Barry <barry
flyerheaven.de>:
> >
> > Martin Alterisio schrieb:
> > > 2006/4/28, Dave Goodchild <buddhamagnet
gmail.com>:
> > >>
> > >> Hi all - I am attempting to solve some maddening behaviour that has
> me
> > >> totally stumped and before I take a blade to my throat I thought I
> > would
> > >> pick the brains of the group/hive/gang.
> > >>
> > >> I am working on a viral marketing application that uses multipart
> > emails
> > >> to
> > >> notify entrants of their progress in the 'game'. I have a demo
> version
> > >> which
> > >> works fine, and the current rebranded version was also fine until the
> > >> client
> > >> asked for some changes then POWWWWW!
> > >>
> > >> I will try and define the issue as simply as I can. I am passing 11
> > >> arguments to a function called sendSantaMail (don't ask) and as a
> > sanity
> > >> check I have called mail() to let me know the values just before they
> > are
> > >> passed in to the function. I get this result:
> > >
> > >
> > > sendSantaMail???? That's just not a *declarative* way of naming a
> > function.
> > Do you know what "santa" means? No? so how can you tell it's not
> > declarative.
> > Santa could be a coded Mailer and that functions uses that specific
> > Mailer Deamon called "santa" to send mails.
>
>
> Yeah you're right, I was thinking the exact same thing a while after I
> posted that. Maybe it was a correct name in the context used, but, I still
> think "Santa" is a really misleading name for a mailer, and not to mention
> that a mass mailer identifying itself as "Santa mailer" in the headers is
> asking to be send directly to spam. Anyway, I was wrong.
>
> > Then, 11 arguments???? Errr, passing an associative array with the email
> > > parameters wouldn't have been a cleaner and better option?
> >
> > He just told he passes 11 arguments, never told how he does that.
>
>
> Well, if somebody tells you a function has 11 arguments what would you
> think?
>
>
--
http://www.web-buddha.co.uk
dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)
look out for project karma, our new venture, coming soon!
attached mail follows:
On Fri, April 28, 2006 8:11 am, Dave Goodchild wrote:
> I am working on a viral marketing application that uses multipart
> emails to
> notify entrants of their progress in the 'game'. I have a demo version
> which
> works fine, and the current rebranded version was also fine until the
> client
> asked for some changes then POWWWWW!
Maybe your scripts have a viral infection? :-)
> I will try and define the issue as simply as I can. I am passing 11
> arguments to a function called sendSantaMail (don't ask) and as a
> sanity
> check I have called mail() to let me know the values just before they
> are
> passed in to the function. I get this result:
>
> "Values to be passed to sendSantaMail:
>
> Friend Name: Treyt
> Friend Email: wonder
brs.com
> Sender Name: Bull Sykes
> Sender Email: chancer
gisat.com
> Prize ID: 1
> Nominator ID: 2555004452133557e4d
> Nominee ID: 851355445213355cc6f
> Chain ID: CHAIN824452133561a8d"
>
> - this is all good and correct. I also call mail from the receiving
> function
> to check the actual values received by the function and I get this:
>
> "Values sent into sendSantaMail function:
>
> Friend Name: chancer
git.com
> Friend Email: Look what you may have won!
> Sender Name: 8 Use of undefined constant prize - assumed 'prize'
I dunno how you managed to get this inte the $name variable, or
whatever, but in line 8 of *SOME* script somewhere, you have something
like:
$foo = prize;
PHP is complaining because prize isn't delimited by quotes or
apostrophes, so you're pretty much pushing PHP up against a wall and
forcing it to GUESS what the heck you meant.
And computers do NOT like to guess. Nosireebob.
So put some quotes around prize and make it "prize" or 'prize'
> Sender Email: 158
I dunno where the 158 is coming from...
Or maybe it's line 158, and the 8 is the number corresponding to
E_NOTICE, and you have a custom error handler outputting E_NOTICE,
which is really 8...
> Sender Email: /home/friend/public_html/process1.php
I'm guessing that the error on line 8 (or maybe 158) is actually in
the file 'process1.php'
If your scripts are passing stuff around to each other, with ':' in
between, this would all make a lot of sense, as you've got one script
printing out an error about line 158 in process1.php, and you've got
another script reading that error output and assuming it's valid data.
> <chancer
git.com>Prize: 1
> Subject: 158
> Nominator ID: 33238744520f5235b85
> Nominee ID: 96658244520f524bb19
> Chain ID: CHAIN84644520f525a56f"
>
> What is happening? I have checked the order of values being passed in
> and
> the function prototype and they match in the correct order, there are
> no
> default values. I have been trying to solve this for two days and am
> particularly concerned that somewhere along the way the sender email
> value
> becomes the script name.
>
> Any ideas on this black Friday?
I don't even want to think about what your code must look like if my
theories are correct...
I just hope to [deity] that these are all opt-in lists or whatever and
I'm not helping some spammer. :-(
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
All my variables are correctly delimited. And don't make assumptions about
what my code looks like - I am asking for help, not judgements, and my
question was valid (unlike many you see here). I am not a spammer either,
this is an application for the marketing department of a charity.
On 29/04/06, Richard Lynch <ceo
l-i-e.com> wrote:
>
> On Fri, April 28, 2006 8:11 am, Dave Goodchild wrote:
> > I am working on a viral marketing application that uses multipart
> > emails to
> > notify entrants of their progress in the 'game'. I have a demo version
> > which
> > works fine, and the current rebranded version was also fine until the
> > client
> > asked for some changes then POWWWWW!
>
> Maybe your scripts have a viral infection? :-)
>
> > I will try and define the issue as simply as I can. I am passing 11
> > arguments to a function called sendSantaMail (don't ask) and as a
> > sanity
> > check I have called mail() to let me know the values just before they
> > are
> > passed in to the function. I get this result:
> >
> > "Values to be passed to sendSantaMail:
> >
> > Friend Name: Treyt
> > Friend Email: wonder
brs.com
> > Sender Name: Bull Sykes
> > Sender Email: chancer
gisat.com
> > Prize ID: 1
> > Nominator ID: 2555004452133557e4d
> > Nominee ID: 851355445213355cc6f
> > Chain ID: CHAIN824452133561a8d"
> >
> > - this is all good and correct. I also call mail from the receiving
> > function
> > to check the actual values received by the function and I get this:
> >
> > "Values sent into sendSantaMail function:
> >
> > Friend Name: chancer
git.com
> > Friend Email: Look what you may have won!
> > Sender Name: 8 Use of undefined constant prize - assumed 'prize'
>
> I dunno how you managed to get this inte the $name variable, or
> whatever, but in line 8 of *SOME* script somewhere, you have something
> like:
>
> $foo = prize;
>
> PHP is complaining because prize isn't delimited by quotes or
> apostrophes, so you're pretty much pushing PHP up against a wall and
> forcing it to GUESS what the heck you meant.
>
> And computers do NOT like to guess. Nosireebob.
>
> So put some quotes around prize and make it "prize" or 'prize'
>
> > Sender Email: 158
>
> I dunno where the 158 is coming from...
>
> Or maybe it's line 158, and the 8 is the number corresponding to
> E_NOTICE, and you have a custom error handler outputting E_NOTICE,
> which is really 8...
>
> > Sender Email: /home/friend/public_html/process1.php
>
> I'm guessing that the error on line 8 (or maybe 158) is actually in
> the file 'process1.php'
>
> If your scripts are passing stuff around to each other, with ':' in
> between, this would all make a lot of sense, as you've got one script
> printing out an error about line 158 in process1.php, and you've got
> another script reading that error output and assuming it's valid data.
>
> > <chancer
git.com>Prize: 1
> > Subject: 158
> > Nominator ID: 33238744520f5235b85
> > Nominee ID: 96658244520f524bb19
> > Chain ID: CHAIN84644520f525a56f"
> >
> > What is happening? I have checked the order of values being passed in
> > and
> > the function prototype and they match in the correct order, there are
> > no
> > default values. I have been trying to solve this for two days and am
> > particularly concerned that somewhere along the way the sender email
> > value
> > becomes the script name.
> >
> > Any ideas on this black Friday?
>
> I don't even want to think about what your code must look like if my
> theories are correct...
>
> I just hope to [deity] that these are all opt-in lists or whatever and
> I'm not helping some spammer. :-(
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
>
>
>
--
http://www.web-buddha.co.uk
dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)
look out for project karma, our new venture, coming soon!
attached mail follows:
On 4/29/06, Dave Goodchild <buddhamagnet
gmail.com> wrote:
> All my variables are correctly delimited. And don't make assumptions about
> what my code looks like - I am asking for help, not judgements, and my
> question was valid (unlike many you see here). I am not a spammer either,
> this is an application for the marketing department of a charity.
Did you try the debug_backtrace idea someone mentioned? What did that show?
Are you passing values in by reference anywhere?
--
Postgresql & php tutorials
http://www.designmagick.com/
attached mail follows:
On Fri, April 28, 2006 8:57 am, T.Lensselink wrote:
>> In the demo version the script accesses the $_GET array - an example
>> value:
>>
>> $data[email]
>>
>> ..which works fine in the demo app. If I quote all the values thus
>> in the
>> new version:
>>
>> $data['email']
>>
>> ..the arguments appear in the correct order. I understand the second
>> format
>> is better to disambiguate constants but the former format works fine
>> for
>> the
>> demo version. Any reason for the discrepancy?
The demo is running on a badly-configured server with the default
value for error_reporting of E_ALL ~ E_NOTICE
So you never *SEE* the error notice message on the demo server --
because it's getting swallowed.
On the REAL server, which is properly configured with E_ALL, you are
seeing the E_NOTICE messages telling you that your code is broken
because not putting quotes there is just plain broken.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On Fri, April 28, 2006 9:01 am, Dave Goodchild wrote:
> Thanks - now the parameters reach the function intact but the mailer
> still
> does not work. Basically, the form is a self-reloader. If the form has
> been
> submitted and the data validated (including emails sent) it displays a
> thank
> you message. Otherwise it shows the starter form.
>
> All that happens when I submit is a white page - no errors
> (display_errors
> is on and error reporting set to the default level) and no html. Nada.
> When
> I try and view source I am given the browser re-post warning.
Probably:
The "demo" server is also badly-configured to show you error messages,
and the "real" server is properly-configured to not display error
messages in the browser.
You'll need to check the Apache error logs and see if the error
messages are there, or check php.ini to see if that's also turned off
-- which it might be for performance reasons...
The big problem is that your code doesn't have any sort of sanity
checking on the data, nor any decent error-handling...
It's way beyond the scope of this list to correct that, really, other
than to tell you that you really need to write a lot more code to
validate your data, and to catch and handle error conditions.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On Fri, April 28, 2006 9:19 am, Dave Goodchild wrote:
> I would do but there are 5000+ lines and no indication of where the
> error is
> occurring. I have just copied the demo version into the same dir and
> it
> works fine - and that version calls the same classes (includes).
Go ahead and let he broser re-post the data when you do "View Source"
and see what you get.
If that does nothing, then add some debug lines in your code to print
out what it is doing where.
There is certainly no way any of us can guess what's wrong in the
5000+ lines any better than you can guess...
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Wrong - both versions run on the same server (virtual hosts but same php.ini).
I will check the values however, thanks!
On 29/04/06, Richard Lynch <ceo
l-i-e.com> wrote:
>
> On Fri, April 28, 2006 8:57 am, T.Lensselink wrote:
> >> In the demo version the script accesses the $_GET array - an example
> >> value:
> >>
> >> $data[email]
> >>
> >> ..which works fine in the demo app. If I quote all the values thus
> >> in the
> >> new version:
> >>
> >> $data['email']
> >>
> >> ..the arguments appear in the correct order. I understand the second
> >> format
> >> is better to disambiguate constants but the former format works fine
> >> for
> >> the
> >> demo version. Any reason for the discrepancy?
>
> The demo is running on a badly-configured server with the default
> value for error_reporting of E_ALL ~ E_NOTICE
>
> So you never *SEE* the error notice message on the demo server --
> because it's getting swallowed.
>
> On the REAL server, which is properly configured with E_ALL, you are
> seeing the E_NOTICE messages telling you that your code is broken
> because not putting quotes there is just plain broken.
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
>
>
>
--
http://www.web-buddha.co.uk
dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)
look out for project karma, our new venture, coming soon!
attached mail follows:
On Fri, April 28, 2006 4:54 pm, OpenMacNews wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> in a given php file, this returns an image as expected:
>
> ...
> $word="blah";
> imagefttext($im, ... other params ... , $word);
> ...
> header ("Content-type: image/png");
> imagepng($im);
> ...
>
> however, if rather than defining $word locally in the script, i
>
> $_SESSION['test']="blah";
>
> elsewhere, then:
>
> $word=$_SESSION['test']="blah";
> imagefttext($im, ... other params ... , $word);
> imagepng($im);
>
> i simply get a blank image. NO error in either the browser or my
> apache
> logs.
>
> a simple test with:
>
> echo $word;
>
> outputs
>
> "blah"
>
> as expected; i.e, the _SESSION var *is* passed.
>
> QUESTION: what's different about the string passed via SESSION?
Just for fun, try it with imagestring.
And, really, show us the image creation and whatnot.
You've trimmed so much out, and we're going to have to second-guess
you and think you just messed up creating the image in the second
script, or that you got the arguments to the imagefttext() wrong,
which is easy to do, since there are so many paramters on those image
functions.
And the bits you've trimmed out wouldn't make your post THAT much
longer. A handful of lines more, if you keep it to a minimum.
TIP:
I always copy and paste the prototype line from the reference manual
as a comment the line before my call to those image functions with
many arguments -- Then I can better track what I'm typing.
Yeah, those fancy IDEs can help too, but I'm an old-school vi kind of
guy -- The IDEs with all the bells and whistles just get in my way
more than they help.
It's pretty hard to see how the string coming from the SESSION could
matter...
Though there WAS one RC version where, as I recall, SESSION strings
were being passed out as, errr, references to strings, even though no
such beast actually exists in PHP User Land...
Altering the string would also alter the session data, which was very
disconcerting.
I don't see how that would apply here, mind you, but you could try this:
$word = '';
$word .= $_SESSION['test'];
The point being that by appending to an existing string, you can be
sure it's a "fresh" string, and not a reference to the string.
The bug I refer to was easily spotted by doing a var_dump on the data
string. It showed "& string" rather than just "string", as I recall.
(Or maybe it was "string &")
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On Fri, April 28, 2006 10:26 am, sathyashrayan wrote:
> I am a self thought php beginner. I wrote my first toy
> code for database connection in php/mysql. The connection
> is successful but iam getting a warning and my rows/columns
> are not showing. I am getting a warning:
>
> Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result,
> boolean given in c:\webs\test\dbs\one.php on line 13
>
> I went through the php manual for the above mentioned function where
> I get no clue. Pls guide me.
>
> code:
>
> <html>
> <head>
> <title> my first data base page </title>
> </head>
> <body>
> <pre>
> <?php
> $conn = mysqli_connect("localhost","root","passwd","temp")
> or die("conn failed");
> $temp1 = "select *from grape_varity";
Put a space after the * in that query.
> $result = mysqli_query($conn,$temp);
Add this:
or die("query failed " . mysqli_error($conn))
to the end of the line, just like you did for the mysqli_connect() above.
> while($row=mysqli_fetch_row($result))
$result is PROBABLY 'false' (which is a boolean value) and that's
PROBABLY because having the * right next to 'from' in the query is
invalid.
But the mysqli_error() function will TELL you what is wrong, instead
of me guessing, and it will be a good habit, since it will tell you
want is wrong if you make mistakes in the future.
> {
> for($i =0;$i < mysqli_num_fields($result);$i++)
> echo $row[i]." ";
> echo "\n";
> }
>
> mysqli_close($conn);
>
> ?>
> </pre>
> </body>
> </html>
>
> [OT]
> And one more thing is if I want to replay to a msg in this mail list
> do I have to hit replay button or replay-all button for posting
> in the mail list. I use "microsoft outlook 2000"
You need Reply-All to hit all of us...
Well, probably. You never know with Microsoft products...
You SHOULD be able to tell by looking at the "To: " fields after you
hit the buttons.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On Fri, April 28, 2006 6:21 am, Schalk wrote:
> Possibly a very simple question but here goes. How would I code the
> following in PHP?
>
> if(window.location == (("http://www.epda.cc/index.php") ||
The closest moral equivalent to window.location in PHP is probably
$_SERVER['PHP_SELF']...
Actually, just var_dump($_SERVER) and pick out the key/value you like
best that suits your needs.
Other than a lot of ((excessive (parentheses))) the rest of it is
fine, I think...
Actually, I don't think you can use this:
$x === ($y || $z)
and have it mean what you want it to mean...
You'd want:
$x === $y || $x === $y
But I do know there are some funky things you can do with || that
aren't what I expect, so I could be wrong on this part.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On Fri, April 28, 2006 3:09 am, Nick Wilson wrote:
> nick
communicontent > ls
> ads/ config.inc db.inc funcs.inc init.inc
>
> where ads/ is a whole huge set of scripts from an existing setup. ads/
> was originally placed on its own domain as it's a version of phpadsnew
> and runs as a server all by itself.
Whoever wrote phpadsnew assumed you don't understand PHP's
include_path, so they tried to be "smart" and used relative paths.
But that ONLY works if you install everything in exactly the same
structure as they thought you should. :-(
> I moved ads/ to this directory to try to troubleshoot and make things
> clearer.
>
> db.inc has these lines:
>
>
> require_once("ads/admin/config.php");
> require_once("lib-statistics.inc.php");
> require_once("lib-zones.inc.php");
> require_once("config.inc.php");
> require_once("lib-db.inc.php");
> require_once("lib-dbconfig.inc.php");
>
> warning: main(../config.inc.php): failed to open stream: No such file
> or
> directory in
> /var/www/localhost/vhosts/payment.communicontent.com/modules/partners/inc/ads/admin/config.php
> on line 33.
>
>
> Fatal error: main(): Failed opening required '../config.inc.php'
> (include_path='.:/usr/lib/php') in
> /var/www/localhost/vhosts/payment.communicontent.com/modules/partners/inc/ads/admin/config.php
> on line 33
So, the ads/admin/config.php is looking for '../config.inc.php' which
is not there.
But it's getting called, as far as we can tell from what you have
posted, from ads/db.inc, in which case the correct path would just be
'config.inc.php', since the base path of db.inc is /ads/ and that's
where 'config.inc.php' is...
It seems awfully odd that db.inc would require 'ads/admin/config.php'
in the first place, tell you the truth...
> So, why does this not happen when ads/ is on its own domain? I can see
> it has something to do with relative paths, but even when i try to
> work
> with chdir() i still get no joy.
I don't think chdir() affects where PHP and include_path look for
include files...
> I just can't figure out what the issue may be, so any pointers in the
> right direction would be hugely appreciated.
I think the first thing I would do would be to make sure that you
restore the code to what is on the other server.
THEN, change your include_path within /ads to be:
'.:/var/www/localhost/vhosts/payment.communicontent.com/modules/partners/inc/ads'
AND, change your include_path within /ads/admin to be:
'.:/var/www/localhost/vhosts/payment.communicontent.com/modules/partners/inc/ads/admin'
Oh!
It's possible, even LIKELY, that when you copied the files over, you
"missed" copying over the .htaccess files that did this for you from
the other server -- because files named with a leading '.' are ignored
by many command line tools (tar, cp, etc) unless you specifically
include them with command flags or list them by name as filenames.
If you are just missing the .htaccess files, just copy those over, and
undo any changes you've been making to try and "fix" the problem. :-)
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Hi,
I am new to this IPN (instant payment
notification.I am working for past 6 hours.I am using
this IPN to store payment details in our database.
when user clicks the paypal button in my page.it
will take to paypal.com website.after user completes
the payments.It will send the payment details to my
page.where i can process and store in the database.
This is the Code for paypal button:
-----------------------------------
<form action="https://www.paypal.com/cgi-bin/webscr"
method="post">
<input type="image"
src="https://www.paypal.com/en_US/i/btn/x-click-but20.gif"
border="0" name="submit" alt="Make payments with
PayPal - it's fast, free and secure!" disabled>
<img alt="" border="0"
src="https://www.paypal.com/en_US/i/scr/pixel.gif"
width="1" height="1">
<input type="hidden" name="notify_url"
value="http://myadtv.com/Gauranga/confirmation_message.php">
<input type="hidden" name="cmd"
value="_xclick-subscriptions">
<input type="hidden" name="business"
value="yvonne
myadtv.com">
<input type="hidden" name="item_name"
value="Subscribe to Additional User Account Yearly">
<input type="hidden" name="item_number"
value="2">
<input type="hidden" name="no_shipping"
value="1">
<input type="hidden" name="no_note"
value="1">
<input type="hidden" name="currency_code"
value="USD">
<input type="hidden" name="bn"
value="PP-SubscriptionsBF">
<input type="hidden" name="a1"
value="0.00">
<input type="hidden" name="p1" value="3">
<input type="hidden" name="t1" value="D">
<input type="hidden" name="a3"
value="59.95">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="Y">
<input type="hidden" name="src"
value="1">
<input type="hidden" name="sra"
value="1">
</form>
------------------------------------------------
my page code to process paypal
------------------------------
<?
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type:
application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) .
"\r\n\r\n";
$fp = fsockopen ('www.paypal.com', 80, $errno,
$errstr, 30);
// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number=$_POST['item_number'];
$shipping_status = $_POST['no_shipping'];
$note_status = $_POST['no_note'];
$currency = $_POST['currency_code'];
$business_name = $_POST['bn'];
$payment_amount = $_POST['a3'];
$payment_duration_num = $_POST['p3'];
$payment_duration = $_POST['t3'];
$txn_id = $_POST['txn_id'];
//$receiver_email = $_POST['receiver_email'];
//$payer_email = $_POST['payer_email'];
$payment_status = $_POST['payment_status'];
if (!$fp)
{
print "$errstr ($errno)<br />\n";
}
else
{
include('db.php');
$transactionidretrieveresult=mysql_query("select
* from BillingInfo where Transaction_ID='$txn_id'");
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
if(($payment_status=="Completed") and
(!mysql_num_rows($transactionidretrieveresult))):
//storing in Database;
endif;
}
elseif (strcmp ($res, "INVALID") == 0)
{
print "Click The Link To Go To MyADTV
Add New User Account Page<a
href=\"adduseraccounts.php\">Click Here</a>";
}
fclose ($fp);
}
?>
When i visit my page i am displaying this error
Undefined index:item_name,Undefined
index:item_number,Undefined index:a1,Undefined
index:p1,Undefined index:t1,Undefined index:a3,and so
on.
I am waiting response from any one
,
__________________________________________________________
Yahoo! India Matrimony: Find your partner now. Go to http://yahoo.shaadi.com
attached mail follows:
On Sat, April 29, 2006 3:53 am, suresh kumar wrote:
> <input type="hidden" name="item_name"
> value="Subscribe to Additional User Account Yearly">
> my page code to process paypal
> ------------------------------
> <?
>
> // read the post from PayPal system and add 'cmd'
> $req = 'cmd=_notify-validate';
>
> foreach ($_POST as $key => $value) {
> $value = urlencode(stripslashes($value));
> $req .= "&$key=$value";
echo "$key => $value<br />\n";
> }
>
> $item_name = $_POST['item_name'];
$item_name = isset($_POST['item_name']) ? $_POST['item_name'] : '';
> Undefined index:item_name
The $_POST data is not filled in, either because this is your FIRST
visit to the page, or because something is not doing a POST request
the way you think it should be.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On Thu, April 27, 2006 9:56 am, Jason Gerfen wrote:
> I have come upon a problem and am not sure how to go about resolving
> it. I have an web form which is generated dynamically from an
> imported
> file and I am not sure how I can loop over the resulting post
> variables