Re: [PHP] PHP Standard style of writing your code

2006-04-29 Thread Paul Novitski



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. 


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



Re: [PHP] we are looking for experienced php programmers full time freelance...

2006-04-29 Thread chris smith

On 4/28/06, Sumeet [EMAIL PROTECTED] 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/

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



Re: [PHP] Help!

2006-04-29 Thread chris smith

On 4/29/06, Dave Goodchild [EMAIL PROTECTED] 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/

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



Re: [PHP] PHP Standard style of writing your code

2006-04-29 Thread Robert Cummings
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... yeeuck ;)

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.  |
`'


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



Re: [PHP] PHP Standard style of writing your code

2006-04-29 Thread Robert Cummings
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.  |
`'

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



Re: [PHP] Possible?

2006-04-29 Thread Richard Lynch
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

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



[PHP] Re: RegExp for preg_split()

2006-04-29 Thread Rafael

Try this (don't pay attention to the name):
  /**
   * @param string  $text
   * @returnarray
   * @since Sat Apr 29 01:35:37 CDT 2006
   * @authorrsalazar
   */
  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

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



Re: [PHP] Possible?

2006-04-29 Thread Richard Lynch
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

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



Re: [PHP] Help!

2006-04-29 Thread Dave Goodchild

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 [EMAIL PROTECTED] wrote:


2006/4/28, Barry [EMAIL PROTECTED]:

 Martin Alterisio schrieb:
  2006/4/28, Dave Goodchild [EMAIL PROTECTED]:
 
  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 POW!
 
  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!


Re: [PHP] PHP Standard style of writing your code

2006-04-29 Thread Rafael
	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

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



RE: [PHP] PHP Standard style of writing your code

2006-04-29 Thread Richard Lynch
On Fri, April 28, 2006 5:18 pm, Chris W. Parker wrote:
 Richard Lynch mailto:[EMAIL PROTECTED]
 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

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



Re: [PHP] PHP Standard style of writing your code

2006-04-29 Thread Richard Lynch
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

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



Re: [PHP] GD text proc via php OK for local strings, but NOT for SESSION-passed strings. why?

2006-04-29 Thread Richard Lynch
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

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



Re: [PHP] Multi-threaded port listener

2006-04-29 Thread Richard Lynch
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

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



Re: [PHP] display_errors off and custom error pages

2006-04-29 Thread Richard Lynch
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=errorAn 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

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



Re: [PHP] Beginner's php/mysql connection probs

2006-04-29 Thread Richard Lynch
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

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



Re: [PHP] Help!

2006-04-29 Thread Richard Lynch
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 POW!

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: [EMAIL PROTECTED]
 Sender Name: Bull Sykes
 Sender Email: [EMAIL PROTECTED]
 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: [EMAIL PROTECTED]
 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.

 [EMAIL PROTECTED]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

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



Re: [PHP] getting current page url

2006-04-29 Thread Richard Lynch
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

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



Re: [PHP] Help!

2006-04-29 Thread Dave Goodchild

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 [EMAIL PROTECTED] 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 POW!

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: [EMAIL PROTECTED]
 Sender Name: Bull Sykes
 Sender Email: [EMAIL PROTECTED]
 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: [EMAIL PROTECTED]
 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.

 [EMAIL PROTECTED]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!


Re: [PHP] RegExp for preg_split()

2006-04-29 Thread Richard Lynch
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

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



Re: [PHP] Help!

2006-04-29 Thread chris smith

On 4/29/06, Dave Goodchild [EMAIL PROTECTED] 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/

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



Re: [PHP] Help!

2006-04-29 Thread Richard Lynch
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

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



Re: [PHP] Help!

2006-04-29 Thread Richard Lynch
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

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



Re: [PHP] Help!

2006-04-29 Thread Richard Lynch
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

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



Re: [PHP] Help!

2006-04-29 Thread Dave Goodchild

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 [EMAIL PROTECTED] 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!


Re: [PHP] Includes and paths confusion

2006-04-29 Thread Richard Lynch
On Fri, April 28, 2006 3:09 am, Nick Wilson wrote:
 [EMAIL PROTECTED]  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



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



[PHP] IPN error

2006-04-29 Thread suresh kumar
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=[EMAIL PROTECTED]
 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 Pagea
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

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



Re: [PHP] forms and dynamic creation and unique field names

2006-04-29 Thread Richard Lynch
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
 within the global $_POST array due to the array keys not being
 numeric.
 Any pointers are appreciated.

function array_dump($data){
  if (is_array($data)){
foreach($data as $key = $value)
  echo $key: ;
  array_dump($value);
  echo br /\n;
}
  }
  else echo $data;
}

array_dump($_POST);

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Uploading pic

2006-04-29 Thread Richard Lynch
On Thu, April 27, 2006 8:15 am, Rosen wrote:
 I have this problem with uploading images:
 I try several PHP classes for upload of files on server ( pictures in
 my
 case ), but if some user only renames some file as .jpg the script
 uploads the file even the file format is not .jpg - i.e. - file
 test.mpg - the user renames it to test.jpg - and the script upload
 it on server. Of course after this the website don't show any pi - it
 shows like pic does not exists.

http://php.net/getimagesize
can be used on the files uploaded to make sure that they at least LOOK
like they are valid images.

A clever user COULD manage to upload a file whose first X bytes
looked like a JPEG, but it was really an .mpg after those X bytes --
but it's really unlikely that the file would work as an .mpg
correctly...

Most likely, it would just be a corrupt file, neight .jpg nor .mpg

   I need also to control the dimension of pictures ( in pixels), size
 in
 kb and type of files ( .gif, .jpg ).

 Is there a way to do this with some script ?

http://php.net/imagecopyresampled
will take care of X and Y

You'd have to output the file with http://php.net/imagejpg and/or
http://php.net/imagegif and then use http://php.net/filesize to
determine how big the file was -- or keep it all in RAM using
http://php.net/ob_start http://php.net/ob_get_contents and
http://php.net/ob_end_clean and then use http://php.net/strlen

You may find that the hassle of worrying about the actual Kb is too
much effort, when you can pretty well predict that a 400x300 JPEG will
be not TOO big (or whatever numbers work for you)

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] error message

2006-04-29 Thread Richard Lynch
On Thu, April 27, 2006 7:46 am, cybermalandro cybermalandro wrote:
 I am running an old version of PHP for winblows 4.3.8. I cannot
 upgrade to
 4.4.2 yet.  I rebooted the web server and the box.  I am not doing any
 exception handling.  I want the errors to be writtent to a log but
 instead
 they keep showing in the browser.  Is there something I am missing? I
 did
 set display_errors to off in the php.ini file.

#1.
Build a page that just does:
?php phpinfo();?

Where does that page claim that your php.ini file is located?

#2.
Is that were your php.ini file is located?
If not, MOVE your php.ini file to that directory.

#3.
Does phpinfo() show the settings for display_errors that you think you
set?
If #1 and #2 are all worked out, this SHOULD be correct...

#4.
In the line before where your error message is appearing, add this:
echo Error reporting has been set to: , error_reporting(), br /\n;
echo Display errors has been set to: , ini_get('display_errors'),
br /\n;

There are only so many ways that this can get messed up, really...

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] IPN error

2006-04-29 Thread Richard Lynch
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 = $valuebr /\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

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



Re: [PHP] php - js (was Javascript Navigation)

2006-04-29 Thread Richard Lynch
On Thu, April 27, 2006 6:39 pm, tedd wrote:
 At 1:57 PM -0700 4/27/06, Paul Novitski wrote:
 variable to js and will cause js to execute. But, isn't there
 anything else? Is that all there is?

That's all there is unless  you really want to chew up all your HTTP
connctions with a hell of a lot of useless information going
back-and-forth...

You could get an ongoing dialog going with PHP and JS as you have done
with AJAX, and you could even get the two of them to send each other
specific messages you would make up that would make the other one poll
back for more info...

But that would be incredibly wasteful.

If you need that kind of real-time client-server interaction, you should:

A) Switch to Java which kinda sorta has a working keep-alive
applet/servelet model.

B) Write a custom client-server application.

But trying to force JS - PHP communication the way you are
describing it is only going to make you very unhappy in the long run.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] display_errors off and custom error pages

2006-04-29 Thread Jochem Maas



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



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



Re: [PHP] PHP Standard style of writing your code

2006-04-29 Thread Porpoise


Rafael [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]


P.S. What, in your mind, is the advantage of replying after quoting the
original message and not before? :)

In an NG environment, it allows everyone to follow the logic and see clearly 
what is being replied to, in the correct context.


IMALOOPHO... 


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



Re: [PHP] PHP Standard style of writing your code

2006-04-29 Thread Robert Cummings
On Sat, 2006-04-29 at 03:17, Richard Lynch wrote:

 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?

Tis true, I think mostly I just prefer the visual appeal of v-aligned
braces, as you prefer visually the other. I used your style for about 7
years before I switched, and now for whatever internal appraisal reasons
I just find the inline style messy looking :) Although, I'll take it any
day over some of the other styles I've seen.

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.  |
`'

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



Re: [PHP] cgi.fix_pathinfo and iis 5

2006-04-29 Thread Jochem Maas

Mariano Guadagnini wrote:

Mariano Guadagnini wrote:


Hi people,
I have the following issue: I´m using PHP 5 on IIS 5 and Windows XP 
Pro, and when trying to pass values through the path to my scripts, 
iis rejects them.  After some googling, I found an advice to set 
AllowPathInfoForScriptMappings variable in iis, but it didn't work 
either. Finally, I ended up with a solution i found somewhere else, 
enabling cgi.fix_pathinfo in php.ini . The thing is, that when i 
restart the server, it seems that php doesn't recognize such variable, 
as it doesn't apper on phpinfo or ini_get() neither. That looks weird, 
because in documentation is clearly stated that this variable is  
available since  PHP 4.3.0 .

What can I do to have that setting enabled?


seeing as it has the letters 'CGI' in the ini setting name would
make me think that it's a setting that is only relevant to the cgi
version of php - and I would wager that your probably running the ISS
php module instead - but you don't say which so I'm guessing.

for the rest refer to John Wells' post.


Thanks in advance,

Mariano Guadagnini.



Any ideas?


1 springs to mind: don't double post.






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



Re: [PHP] PHP Standard style of writing your code

2006-04-29 Thread Satyam

On Sat, 2006-04-29 at 03:17, Richard Lynch wrote:


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?


I prefer the opening brace at the end of the line as well.  I rather see as 
much of the code as possible.  Wasting one line for an openning brace, and 
not only function declarations but any opening brace, is a waste of screen 
space.  My eyes are no longer good enough to have microscopic screen 
resolutions so within the resolution I use plus all the toolboxes, I still 
want to be able to see a good chunk of the code.


For me, the visual consequence of an opening brace is the indentation of the 
line following it.  The brace by itself is just what tells the compiler to 
start the statement block.  The visual clue, for me, is the indentation, 
something I am very strict about. The compiler cannot read indentations. 
So, since the brace is for the benefit of the compiler, not mine, I don't 
devote a whole line to it.  Braces for the compiler, indentation for me.


And it is not that I don't like to waste space in general, I am generous 
with my lines before the function declaration or any other place where I 
feel it deserves it for clarity.  In C I put one or more blank lines in 
between the local variable declaration and the first executable, that is a 
space that is worth for clarity sake.  I would also put spaces before a 
#ifdef or after a #endif, those are spaces that say something to me.


A brace on its own line doesn't make sense to me.

Satyam

Satyam

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



Re: [PHP] php - js (was Javascript Navigation)

2006-04-29 Thread tedd

At 4:54 AM -0500 4/29/06, Richard Lynch wrote:


But trying to force JS - PHP communication the way you are
describing it is only going to make you very unhappy in the long run.


Been to that dance more than once. But, as Dirty Harry once said A 
man's got to know his limitations.


Thanks for all your help -- you guys have been super.

tedd
--

http://sperling.com

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



Re: [PHP] PHP Standard style of writing your code

2006-04-29 Thread Rafael
	Thanks for your reply.  Paul Novitski already talked with me about it 
(in private), and my conclusions were...

-
	I guess that has something to do with the way *I* read my mails, since 
I'm usually aware what people are talking about (since I've wrote the 
one they're responding, or I've been following the thread)


	I think you have a pretty good reason, but I also think it doesn't work 
for me --since I have to skip the whole message I've already read, or 
what I wrote :)  Thanks for your answer (and so fast)

-
	I guess this is just one more of the too-many-already debatible points 
out there.  At the end, is a matter of taste, I can't see any as the 
right nor wrong option.


PS	I'd ask you a favor: do not include the email in the quotation, since 
these message are usually available (via http) in some sites, and having 
my email there makes a lot easier for me to get (even) more spam

PPS WTF is IMALOOPHO?

Porpoise wrote:
Rafael email-was-here wrote in message 
news:[EMAIL PROTECTED]


P.S. What, in your mind, is the advantage of replying after quoting the
original message and not before? :)

In an NG environment, it allows everyone to follow the logic and see 
clearly what is being replied to, in the correct context.


IMALOOPHO...

--
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

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



RE: [PHP] PHP Standard style of writing your code

2006-04-29 Thread tedd

At 2:12 AM -0500 4/29/06, Richard Lynch wrote:

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.


Well, that settles it -- if non-programmers like it, then it must be 
correct. :-)


It reminds of a time where a large oil company's Geophysicist was 
evaluating other consulting Geophysicist's work (I was one -- see 
http://geophysics.com ). He took our work product (highly technical 
seismic displays) and hung them on a wall and had everyone in the 
office (accountants, secretaries, UPS delivery man, etc.) parade by 
and pick the display they thought looked the best. To the winner, he 
awarded a multimillion dollar contract!


It had to be the worst way to evaluate a Geophysicist I have ever witnessed.

---

I daresay an experienced programmer is going to pick the style they
prefer as prettier.


I don't know about prettier, but I certainly strive that every piece 
of code I write to have a consistent style that I recognize as mine. 
Plus, when I see another programmer use the same style, I naturally 
assume that he's very intelligent. :-)


Additionally, the style I've developed cuts across several languages 
I've known.


--

Though it would be an interesting experiment for some psychology
student to A/B compare with programmers, non-programmers, experienced
programmers, etc...


That may be an interesting study as to how we perceive and solve 
problems -- anal-retentive vs the free-will types and all variations 
in between. Each, I am sure, has their place in the overall scheme of 
things.


But, I will pass on to the group here that I have noticed (over the 
last 40 years ) in my programming that the size of my monitor is 
generally in direct relationship with the size of my functions.


In addition, the larger my monitors, the more white space I use in 
making my code pretty and documented. In my view, there is no 
wasted space -- just a way to reduce my confusion.


tedd
--

http://sperling.com

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



Re: [PHP] PHP Standard style of writing your code

2006-04-29 Thread tedd

A brace on its own line doesn't make sense to me.

Satyam


As the old lady said, as she kissed the cow To each their own.

It make perfect sense to me to enclose all blocks of code within 
braces on their own line AND to indent that entire segment, like so.


function, if, while, switch, whatever...
  {
  // code
  }

But, like I said -- to each their own. The above just makes sense to 
me and that's what this entire thread should be about -- do whatever 
makes you comfortable and productive.


The last thing I would want is to have someone tell me what style I *must* use.

tedd
--

http://sperling.com

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



Re: [PHP] Help!

2006-04-29 Thread Jochem Maas

Dave Goodchild wrote:
All my variables are correctly delimited. 


strings constants are delimited not variables, semantically speaking.

And don't make assumptions about what my code looks like 


why not? besides how are you going to stop someone from assuming your
code looks like [x]?

- I am asking for help, not judgements, and my

Richard didn't judge, he merely aired a thought (and added 'if my
theories are correct' for good measure).

 besides you only control the question not the answer.

oh and Richard is one of the best people on this list to be helping you
- alienating him isn't in your best interests.

question was valid (unlike many you see here). 


the validity of the question is a matter of consensus, again
something you don't control.


I am not a spammer either,
this is an application for the marketing department of a charity.


charities can potentially spam just as much as anybody - that they happen to
have a 'good cause' doesn't give them a 'get out of jail free' card, they have 
to
obey the email-marketing rules just like any other organization.

ad
'buy a lovely WNF cuddly toy to help protect endangered animals'
(hand made by an 8 y/o in china)
/ad

...

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



[PHP] XML Parsing, starting out.

2006-04-29 Thread sinai
Hello, 1st msg here so im excited what results i will get :)

Im a novice with php parsing and have been able to help myself quite well with 
what ive needed with xml_parse_into_struct and then echoing the fixed variable 
names but now im dealing with an xml document that is 1st quite large and 2nd 
changing gradually over time with either added data or changed information. 
(But not in large numbers)

http://www.camelotherald.com/xml/spells-si.xml

It is a spell listing for an online mmorpg. It has a spell_list that captures 
all other tags and a spell_line for each spell line. Within each spell line 
is a spell which has the detailed info for each spell with in the spell_line

I could parse this by echoing the fixed variables but due to its size and the 
changes done over time its just to much work. This is why i come to a stop. Ive 
read some guides and tried some example code that should help me through this.

What i hoped to get is an example with the xml i provided so i could work with 
it to complete the project.

The example could look something like this:

Header with the selected spell_line name ie. Calefaction and below that the 
spell info in some dummy table format. Then the next spell_line which is 
Path of Earth then with the spell info in some dummy table setup.

Thanks for reading and i hope someone can show me the light of a real xml parse.

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



RE: [PHP] RegExp for preg_split()

2006-04-29 Thread Weber Sites LTD
Thanks,

But this example seems to be short and does the job :

?php
$String='this is a test expression for search input';
$MyRegEx = '/[^]+|[^\s,]+/';
preg_match_all($MyRegEx, $String, $Tokens);  
?

Unless I'm missing something?

thanks

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Saturday, April 29, 2006 10:29 AM
To: Weber Sites LTD
Cc: php-general@lists.php.net
Subject: Re: [PHP] RegExp for preg_split()

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

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

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



Re: [PHP] RegExp for preg_split()

2006-04-29 Thread tedd

Hi:

A summation of entries.

http://xn--ovg.com/a/parse.php

neat!

tedd

--

http://sperling.com

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



Re: [PHP] Re: php - js (was Javascript Navigation)

2006-04-29 Thread Jochem Maas

hi normally,

tedd wrote:

At 9:03 AM +0200 4/28/06, Barry wrote:


tedd schrieb:


At 5:09 PM +0200 4/27/06, Barry wrote:


tedd schrieb:


Hi gang:


Gang?



Gang, group, clan, community, organization, hive, pod, assembly, 
biocenosis -- what do you want to be called?



By my name normally. 


can I shorten that to 'norm'? or did you mean 'usually' in which case
given that I'm odd/unusual/abnormal can I call you something else?

And if you adress everyone i prefer everyone

preferences are like standards - there alot of them.


Two things:

1. My post wasn't by name, but to the list.

2. And, in doing so, I prefer gang. After all, this is an informal 
group and everyone is permitted their preferences, right?


tedd - you wanna say 'gang' you do that :-)
you had me a 'hi' ;-) [ok that was a crap Jerry Maguire reference I know.]

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



Re: [PHP] we are looking for experienced php programmers full time freelance...

2006-04-29 Thread tedd

At 8:44 PM +0200 4/28/06, Jochem Maas wrote:

RANTING SEASON HAS OPENED - lets shoot some wabbits.

has anyone else noticed?? all our jobs go to India and now they are starting
to hire us back. (because they don't have the skills? and probably at rates
that equate to being able to buy 1 cheese sandwich a month with 
change leftover

to play a song on the jukebox - not that they'd let you into the bar seeing as
you can't afford to buy a drink) go figure.


rant

Funny you should say that -- it has happened to me. I have been 
approached by several Indian companies over the years (for more than 
just programming -- oil exploration, gems, etc.) .


However, considering the experiences I've had with Indians, I don't 
mean to sound racist, but I have found there is a significant 
difference between our cultures with respect to the meaning of your 
word -- and as such, I will not do business with any Indian company 
NOR with any company (domestic or overseas) that hires an Indian to 
negotiate a contract!


I have found it is simply a waste of my time to try to find 
profitable common ground. They are concerned with one thing, and one 
thing only, and that is how cheap can they get it -- and they seldom 
have a clue as to what it is -- but, contrary to their lip-service, 
it certainly isn't quality.


I have seen them waste several million dollars to save less than ten 
thousand (no lie). It was with an oil deal, not programming, and 
these people were just plain stupid.


/rant

tedd

--

http://sperling.com

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



Re: [PHP] IPN error

2006-04-29 Thread Stephen Lake
Use cURL I found it much easier then using fsockopen

http://ca.php.net/cURL


Richard Lynch [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 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 = $valuebr /\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 

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



Re: [PHP] IPN error

2006-04-29 Thread Stephen Lake
One more thing, make sure you validate ALL data that is being sent from 
paypal to ensure what you need and expect are therealso validate the 
transaction ID to ensure it was never used before.


Stephen Lake [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Use cURL I found it much easier then using fsockopen

 http://ca.php.net/cURL


 Richard Lynch [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
 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 = $valuebr /\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 

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



[PHP] php login

2006-04-29 Thread Schalk

Greetings All,

Where can I find a good tutorial on creating a login protected area 
using php? I did a Google search and found a couple but, I would like to 
get suggestions from the list. Thanks!


--
Kind Regards
Schalk Neethling
Web Developer.Designer.Programmer.President
Volume4.Business.Solution.Developers

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



Re: [PHP] we are looking for experienced php programmers full time freelance...

2006-04-29 Thread Paul Novitski

At 10:46 AM 4/29/2006, tedd wrote:
...
I have found it is simply a waste of my time to try to find 
profitable common ground. They are concerned with one thing, and one 
thing only, and that is how cheap can they get it -- and they seldom 
have a clue as to what it is -- but, contrary to their 
lip-service, it certainly isn't quality.

...

Whoa!  They they they...  Tedd, there are stupid, venal people 
everywhere in the world, and smart and honorable ones 
besides.  Speaking from personal experience I know that there are 
cultural divides so wide that what's honorable on one side appears 
dishonorable from the other; truth appears as lies; respect appears 
as disrespect; discretion as conspiracy; elegance as boorishness.  To 
judge individuals despite these fundamental differences and then to 
paint an entire nation of people based on one's experiences with a 
few seems lacking in sense, respect, rationality, and honor (speaking 
from this side of your and my cultural divide!).  You're free to form 
your own prejudices based on your experiences, of course, but I'm 
astonished that you would voice them publicly.  I'm embarrassed by 
your comments.


Paul 


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



Re: [PHP] we are looking for experienced php programmers full time freelance...

2006-04-29 Thread Dave Goodchild

Hear hear. This is not the place for this kind of poison. Open source - open
mind.

On 29/04/06, Paul Novitski [EMAIL PROTECTED] wrote:


At 10:46 AM 4/29/2006, tedd wrote:
...
I have found it is simply a waste of my time to try to find
profitable common ground. They are concerned with one thing, and one
thing only, and that is how cheap can they get it -- and they seldom
have a clue as to what it is -- but, contrary to their
lip-service, it certainly isn't quality.
...

Whoa!  They they they...  Tedd, there are stupid, venal people
everywhere in the world, and smart and honorable ones
besides.  Speaking from personal experience I know that there are
cultural divides so wide that what's honorable on one side appears
dishonorable from the other; truth appears as lies; respect appears
as disrespect; discretion as conspiracy; elegance as boorishness.  To
judge individuals despite these fundamental differences and then to
paint an entire nation of people based on one's experiences with a
few seems lacking in sense, respect, rationality, and honor (speaking
from this side of your and my cultural divide!).  You're free to form
your own prejudices based on your experiences, of course, but I'm
astonished that you would voice them publicly.  I'm embarrassed by
your comments.

Paul

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





--
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!


Re: [PHP] undefined variable

2006-04-29 Thread Martin Alterisio

2006/4/29, Smart Software [EMAIL PROTECTED]:


code below shows all records from products table with an textbox and an
order button for each record

? $query1 = mysql_query(SELECT * FROM products );
while ($rowType = mysql_fetch_array($query1))
{ ?
table width=500 border=0
   tr class=largeheader
td width=40%?  echo $rowType[0]; ?/a /td
td width=10%?php  echo $rowType[1]; ?/td
td width=10%input name=quantity type=text value=1 size=1
maxlength=3/td
td width=40% a href=? echo
products.php?cat=$cattoevoegen=1id=$rowType[7]; ?img
src=images/bestel1.gif border=0/a/td
/tr

?php
}
?
/table



if someone presses the button, an item will be ordered.

How can i add the content of the textbox?
i tried this:
td width=40% a href=? echo
products.php?cat=$catquantity=$quantitytoevoegen=1id=$rowType[7];
?img src=images/bestel1.gif border=0/a/td

but all i get is an error telling me there is a undefined varable



Can you post what the error looks like?

thanx for all help

N. Karademir

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




Re: [PHP] Help!

2006-04-29 Thread Martin Alterisio

That's ok, but then I can't help you more than I tried to.
Just check with what I told you about debug_backtrace(), at least that way
you can trace where the function was called with wrong arguments.

2006/4/29, Dave Goodchild [EMAIL PROTECTED]:


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  [EMAIL PROTECTED] wrote:

 2006/4/28, Barry  [EMAIL PROTECTED]:
 
  Martin Alterisio schrieb:
   2006/4/28, Dave Goodchild [EMAIL PROTECTED]:
  
   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 POW!
  
   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!



Re: [PHP] XML Parsing, starting out.

2006-04-29 Thread Richard Lynch
On Sat, April 29, 2006 11:19 am, [EMAIL PROTECTED] wrote:
 Im a novice with php parsing and have been able to help myself quite
 well with what ive needed with xml_parse_into_struct and then echoing

In an ideal world, you would examine other XML parsing options, such
as the PEAR library.

If, like me, the machine in question does not have, and is unlikely to
have, anything BUT the expat library in the near future, a pointer to
a function that uses expat and creates something less unwieldy than
the xml_parseintostruct would be most welcome...  So let me know if
anybody responds off-list, please.

I'll be Googling for it Monday morning myself.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Help!

2006-04-29 Thread Richard Lynch
On Sat, April 29, 2006 11:11 am, Jochem Maas wrote:
 Dave Goodchild wrote:
 All my variables are correctly delimited.

 strings constants are delimited not variables, semantically speaking.

Not to mention that they CANNOT be correctly delimited, or you would
NOT be seeing that error message.

It's that simple.

You SHOULD have the apostrophes (or quotes) on non-numeric array indices.

PHP issues an E_NOTICE error message if you don't.  You may have
suppressed that message, and chosen to ignore it, but that doesn't
fix the code.

After all, using the SAME mechanism of suppression, you can choose to
ignore ALL PHP errors, no matter how drastic.  Surely you cannot claim
that ignoring an error that halts the script in the middle of
execution is somehow correct

 And don't make assumptions about what my code looks like

 why not? besides how are you going to stop someone from assuming your
 code looks like [x]?

One HAS to make assumptions about the code when you fail to post
sufficient information about the code to correctly answer your
question.

 - I am asking for help, not judgements, and my

 Richard didn't judge, he merely aired a thought (and added 'if my
 theories are correct' for good measure).

   besides you only control the question not the answer.

 oh and Richard is one of the best people on this list to be helping
 you
 - alienating him isn't in your best interests.

You have to work at it pretty hard to alienate me... :-)

 I am not a spammer either,
 this is an application for the marketing department of a charity.

 charities can potentially spam just as much as anybody - that they
 happen to
 have a 'good cause' doesn't give them a 'get out of jail free' card,
 they have to
 obey the email-marketing rules just like any other organization.

Yeah, I get a fair amount of spam from otherwise legitimate charities.

Which is a shame, since then they DEFINITELY are not getting any money
from me, ever again.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] undefined variable

2006-04-29 Thread John Wells

 2006/4/29, Smart Software [EMAIL PROTECTED]:
 How can i add the content of the textbox?
 i tried this:
 td width=40% a href=? echo
 products.php?cat=$catquantity=$quantitytoevoegen=1id=$rowType[7];
 ?img src=images/bestel1.gif border=0/a/td

 but all i get is an error telling me there is a undefined varable



It looks like you're trying to get at $quantity, but have you pulled
it from the submitted form yet? If your form's method is post then
reference the quantity value with $_POST['quantity']; if your form's
method is get, use $_GET['quantity'].

You sound very new to this, and the fact that you're building a
shopping cart is worrisome...so please read up on the importance of
verifying your form data, i.e. always sanitize submitted values
before using them in SQL calls. And simply check that the values you
get are what you expect, i.e. if you're expecting a number in
$_POST['quantity'], make sure it's a number...

By the way, values submitted in a form will be strings, so in the
example above you'd actually be checking for the *existence of numbers
only* in the string.  Good luck.

HTH,
John W

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



Re: [PHP] undefined variable

2006-04-29 Thread Richard Lynch
On Sat, April 29, 2006 5:42 am, Smart Software wrote:
 code below shows all records from products table with an textbox and
 an
 order button for each record

 How can i add the content of the textbox?
 i tried this:
 td width=40% a href=? echo
 products.php?cat=$catquantity=$quantitytoevoegen=1id=$rowType[7];
 ?img src=images/bestel1.gif border=0/a/td

 but all i get is an error telling me there is a undefined varable

You probably are following some kind of tutorial that assumes
register_globals is on -- or you are simply used to that
environment.

So when you try to use $quantity, it's not defined.

The value you want is in $_REQUEST['quantity'];

You should do something like this:

?php
  //Get data from REQUEST:
  $quantity = isset($_REQUEST['quantity']) ? $_REQUEST['quantity'] : 0;
  //Force valid data:
  $quantity = (int) $quantity;
  //rest of script here.
?

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] PHP Standard style of writing your code

2006-04-29 Thread Richard Lynch
On Sat, April 29, 2006 9:56 am, Satyam wrote:
 The compiler cannot read
 indentations.
 So, since the brace is for the benefit of the compiler, not mine, I

[pedantic]
Actually, a compiler could use indentation, and, in fact, compilers
for some languages do just that.
[/pedantic]

That style of language definitely sucks, imho, but let's not get THAT
far off-topic, eh?

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] PHP Standard style of writing your code

2006-04-29 Thread Miles Thompson

At 03:19 AM 4/29/2006, Robert Cummings wrote:


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)

nsip
 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.


Poorstyle:

drunken(){
echo Lopsided me;
}

Goodstyle:

drunken()
{
echo Supported me;
}

But the question arises, in goodstyle - should one indent the braces?

I used to code goodstyle, more and more it's poorstyle - nad the 
computer doesn't care, and Ultraedit can match braces, which helps when I 
get lost. I wish UE would also fold code.


With tongue firmly in cheek - cheers - Miles



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.1.385 / Virus Database: 268.5.1/327 - Release Date: 4/28/2006

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



Re: [PHP] XML Parsing, starting out.

2006-04-29 Thread Mattias Thorslund
[EMAIL PROTECTED] wrote:
 Hello, 1st msg here so im excited what results i will get :)

 Im a novice with php parsing and have been able to help myself quite well 
 with what ive needed with xml_parse_into_struct and then echoing the fixed 
 variable names but now im dealing with an xml document that is 1st quite 
 large and 2nd changing gradually over time with either added data or changed 
 information. (But not in large numbers)

 http://www.camelotherald.com/xml/spells-si.xml

 It is a spell listing for an online mmorpg. It has a spell_list that 
 captures all other tags and a spell_line for each spell line. Within each 
 spell line is a spell which has the detailed info for each spell with in 
 the spell_line

 I could parse this by echoing the fixed variables but due to its size and the 
 changes done over time its just to much work. This is why i come to a stop. 
 Ive read some guides and tried some example code that should help me through 
 this.

 What i hoped to get is an example with the xml i provided so i could work 
 with it to complete the project.

 The example could look something like this:

 Header with the selected spell_line name ie. Calefaction and below that 
 the spell info in some dummy table format. Then the next spell_line which 
 is Path of Earth then with the spell info in some dummy table setup.

 Thanks for reading and i hope someone can show me the light of a real xml 
 parse.
   

The comments on the Manual page
[http://www.php.net/manual/en/ref.xml.php] contain an example class that
parses an XML file into an associative array. I'm using something
similar myself, as it seems to be a pretty straightforward way to get an
easy-to-use structure in PHP 4 without dom_xml, which isn't always
available.

Mattias

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



Re: [PHP] RegExp for preg_split()

2006-04-29 Thread Rafael
	LOL  It's interesting that you've taked your time and build that 
'summation', maybe the only thing is missing is the code itself ;)
Now, because you didn't add it, I had to check the different versions, 
and I agree with John Hicks, his suggestion seems to be the best one.


tedd wrote:

A summation of entries.

http://xn--ovg.com/a/parse.php

neat!
tedd

--
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

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



Re: [PHP] PHP Standard style of writing your code

2006-04-29 Thread Robert Cummings
On Sat, 2006-04-29 at 10:56, Satyam wrote:

 A brace on its own line doesn't make sense to me.

This begs the question... Where do you place the closing brace?

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.  |
`'

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



Re: [PHP] XML Parsing, starting out.

2006-04-29 Thread Ólafur Waage

Mattias Thorslund wrote:


[EMAIL PROTECTED] wrote:
 


Hello, 1st msg here so im excited what results i will get :)

Im a novice with php parsing and have been able to help myself quite well with 
what ive needed with xml_parse_into_struct and then echoing the fixed variable 
names but now im dealing with an xml document that is 1st quite large and 2nd 
changing gradually over time with either added data or changed information. 
(But not in large numbers)

http://www.camelotherald.com/xml/spells-si.xml

It is a spell listing for an online mmorpg. It has a spell_list that captures all other tags and a 
spell_line for each spell line. Within each spell line is a spell which has the detailed info 
for each spell with in the spell_line

I could parse this by echoing the fixed variables but due to its size and the 
changes done over time its just to much work. This is why i come to a stop. Ive 
read some guides and tried some example code that should help me through this.

What i hoped to get is an example with the xml i provided so i could work with 
it to complete the project.

The example could look something like this:

Header with the selected spell_line name ie. Calefaction and below that the spell info in some 
dummy table format. Then the next spell_line which is Path of Earth then with the spell info in 
some dummy table setup.

Thanks for reading and i hope someone can show me the light of a real xml parse.
 
   



The comments on the Manual page
[http://www.php.net/manual/en/ref.xml.php] contain an example class that
parses an XML file into an associative array. I'm using something
similar myself, as it seems to be a pretty straightforward way to get an
easy-to-use structure in PHP 4 without dom_xml, which isn't always
available.

Mattias

 

I have been trying as i said above with the php.net examples, the 
sitepoint examples (which have been great to give me some view of what i 
need and how it functions basicly) but with no luck. I can make it easy 
with fixed value but the dynamic part of it is still outside my reach 
for now. Thanks for the examples Matt and Richard


- olafurw

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



Re: [PHP] php login

2006-04-29 Thread chris smith

On 4/30/06, Schalk [EMAIL PROTECTED] wrote:

Greetings All,

Where can I find a good tutorial on creating a login protected area
using php? I did a Google search and found a couple but, I would like to
get suggestions from the list. Thanks!


Just found a good one.. it's a little more complicated than most
because it has the userlevel stuff included.. but gives you some
ideas.

http://www.evolt.org/article/PHP_Login_System_with_Admin_Features/17/60384/index.html

(Found a couple of bugs in it, but you get that)..

Basically you keep usernames/passwords in a database table, after
checking the details, store the login in the session and voila! done!

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] php login

2006-04-29 Thread Schalk

chris smith wrote:

On 4/30/06, Schalk [EMAIL PROTECTED] wrote:

Greetings All,

Where can I find a good tutorial on creating a login protected area
using php? I did a Google search and found a couple but, I would like to
get suggestions from the list. Thanks!


Just found a good one.. it's a little more complicated than most
because it has the userlevel stuff included.. but gives you some
ideas.

http://www.evolt.org/article/PHP_Login_System_with_Admin_Features/17/60384/index.html 


Thanks Chris, I will check it out.

--
Kind Regards
Schalk Neethling
Web Developer.Designer.Programmer.President
Volume4.Business.Solution.Developers

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



[PHP] converting REST result to SOAP object

2006-04-29 Thread Anthony Ettinger

is there a easy way of converting an xml REST result to an object
returned by a SOAP call?

I know I can simply parse the REST and put it in a hash, curious if
there's a method of doing this.

simplexml_load_string() seems to give me simplexml objects inside my
multi-level hash, which isn't really what I want.

--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

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



RE: [PHP] [JOB] PHP developered needed in Largo, MD

2006-04-29 Thread Jay Blanchard
[snip]
Hey Jay!  We run linux here... you could leave your Windows world again!
:)
[/snip]

Thanks, but I have to stay where I am for a while. Sounds like an
interesting project though...

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



Re: [PHP] New Help with Javascript Navigation

2006-04-29 Thread Gerry D

Yah, and why are people still mindlessly clicking OK to install ActiveX plugins?

On 4/27/06, Porpoise [EMAIL PROTECTED] wrote:


Gerry D [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Interesting discussions... :)

I see two issues:

1. if you are exposing php scripts to the client, how does the server
side processing know what it should do and what the client should see?

2. and why can't JS write to the client's file system? Or read from
files? Come to my website and let me first read all your private
information, then trash it... Hackers and other cyber vandals would
love you to implement this feature... LOL
/Gerry D

Isn't that feature called ActiveX??


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



[PHP] simplexml and serialize error

2006-04-29 Thread Anthony Ettinger

Warning: var_dump() [function.var-dump]: Node no longer exists in
Foo.php on line 78
object(SimpleXMLElement)#86 (0) { } [title]=

I turn an xml string into a simplexml object, and then ran serialize()
on it before caching the output locally. When I read it back in and
run unserialize() to do a dump, I get this error.

--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

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



RE: [PHP] Re: php - js (was Javascript Navigation)

2006-04-29 Thread Jay Blanchard
[snip]
...interesting conversation...
[/snip]

Stateless applications, ain't they fun?

I did a little experiment before Ajax cam into vogue with a small PHP
script that essentially ran a while loop with some sleep cycles built
in. This was placed in an iframe and another page was placed in another
iframe with javascript to update the second iframe if data had changed
in the first iframe based on a query running while PHP cycled the loop.
OB functions were used and it worked.

Clear?

So that experiment lead to a meta-refresh of the page in the first
iframe which then ran some PHP code that output some JavaScript to
update the second iframe. It worked better, but had its moments.

The point was to make the user experience better, a manager could see
that certain things were happening without having to refresh a page
manually. Also, a smaller more efficient query could be run and if the
data had not changed the system would not have to endure the overhead of
the larger query.

The end result? A stateless application with simulated statemuch
like what Ajax does today. Really, it was as Ajax as could be, just not
using the httpRequest doohickey, or whatever it is.

There is a wide gulf between stateless applications and applications
with state. Even Java uses a hacked stateless connection (by having
something run client-side sending info a to listener on the
server...what does that sound like?). Isn't the intent for client server
apps to be stateless? Applications with state typically share memory
resources.



 

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



Re: [PHP] Multi-threaded port listener

2006-04-29 Thread D. Dante Lorenso

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).


Building it yourself can be lots of fun and I have done this using 
stream_select, fork, and other PCNTL and IPC functions. If you like 
Pear, you can check out the Net Server package there. They have models 
to do the forking for you for each client connection:


http://pear.php.net/package/Net_Server

Although I didn't use Net Server, I did review the code to get ideas on 
how I'd like to build my server. It is useful.


Dante

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



Re: [PHP] PHP Standard style of writing your code

2006-04-29 Thread D. Dante Lorenso



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! :-)



Without caring what style you prefer, the correct reply to this request 
is the following:


   You seek a Code Beautifier for PHP.

I have found that only some IDE/Editor software contains such a beast.  
The convention for most software code editing tools is to have Shift + 
Ctrl + F do code formatting.  I use PHP Eclipse to handle all my code 
formatting.  It will allow you to choose your preference for braces up 
or down etc.


However...you may need to make a policy in your company.  If you use 
source control for your software, it may see changes in formatting as a 
distinct major revision.  Therefore, if you save code in your style 
and another developer opens the file and resaves in his style, then 
you'll unnecessarily make version control a nightmare.  Despite personal 
preference, you MUST adhere to the style of the project.  If you are the 
sole developer, you define that style.  If you are a coding monkey, then 
you may have to suffer with the style that the architect before you 
declared.


I can't work unless the code is formatted to my liking.  I'm the OCD 
type of programmer.  Luckily I'm also in control of coding standards 
within my company, whew!  Get PHP Eclipse and do a general search for 
PHP Code Beautifier then download some you like and try them out.


Beautiful code often contains fewer bugs.

Dante


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



Re: [PHP] XML Parsing, starting out.

2006-04-29 Thread Gonzalo Monzón

[EMAIL PROTECTED] escribió:


Hello, 1st msg here so im excited what results i will get :)

Im a novice with php parsing and have been able to help myself quite well with 
what ive needed with xml_parse_into_struct and then echoing the fixed variable 
names but now im dealing with an xml document that is 1st quite large and 2nd 
changing gradually over time with either added data or changed information. 
(But not in large numbers)

http://www.camelotherald.com/xml/spells-si.xml

It is a spell listing for an online mmorpg. It has a spell_list that captures all other tags and a 
spell_line for each spell line. Within each spell line is a spell which has the detailed info 
for each spell with in the spell_line

I could parse this by echoing the fixed variables but due to its size and the 
changes done over time its just to much work. This is why i come to a stop. Ive 
read some guides and tried some example code that should help me through this.

What i hoped to get is an example with the xml i provided so i could work with 
it to complete the project.

The example could look something like this:

Header with the selected spell_line name ie. Calefaction and below that the spell info in some 
dummy table format. Then the next spell_line which is Path of Earth then with the spell info in 
some dummy table setup.

Thanks for reading and i hope someone can show me the light of a real xml parse.

 


Hi,

Some months ago I was looking for some code for loading dynamic xml 
data structures my php scripts. I didn't found anything simple and 
flexible for my needs.


I found handy the PEAR XML_beautifier tokenizer, and then I write a 
simple function to extract all the data with the right array structure 
as needed for my project. A recursive function to extract tag elements 
data from the tokenized arrays (attached below)


Have a look at the code below. In some lines I process part of the 
contents from your xml sample file, so you can have something to get 
started, it you find handy my approach.


I've attached a partial output from the data extracted by this code too.

To run the code you need PEAR and XML_Beautifier and dependencies (if 
any, now don't remember if XML_parser is in the PEAR base install or not).


Have fun, :-)

Gonzalo Monzón

?php
ini_set('include_path',./pear;../);

require_once 'PEAR.php';
require_once 'xml/Beautifier/Tokenizer.php';

$xmlsrc = http://www.camelotherald.com/xml/spells-si.xml;;

$data = XML_tokenize($xmlsrc,True);
$spell_list = _gxml_bds_extract_tag('spell_list','children',$data);   


// Extract spell_lines attribute data:
$spell_lines_attr = 
_gxml_bds_extract_tag('spell_line','attribs',$spell_list,1,-1);   


// Extract spell_lines children data:
$spell_lines_data = 
_gxml_bds_extract_tag('spell_line','children',$spell_list,1,-1);   


// Extract spell data and attributes from spell_lines:
foreach($spell_lines_data as $k = $val) {
   $spells_attr[$k] = 
_gxml_bds_extract_tag('spell','attribs',$val,1,-1);   
   $spells_data[$k] = 
_gxml_bds_extract_tag('spell','children',$val,1,-1);   
  
   // Extract data from all spells in $k spell_line:

   foreach($spells_data[$k] as $k2 = $val2) {
   $tmp = _gxml_bds_extract_tag('level','children',$val2);   
   $spells_data_val[$k][$k2]['level'] = $tmp[0]['data'];
  
   $tmp = _gxml_bds_extract_tag('damage_type','children',$val2);   
   $spells_data_val[$k][$k2]['damage_type'] = $tmp[0]['data'];

   }
  
}


/*
(A)
**
*/
echo $spell_lines_attr[0]['name']./br;

foreach($spells_attr[0] as $k = $val) {
   echo $k./br;
   _print_bDS($val);
   _print_bDS($spells_data_val[0][$k]);
   echo /br;
}

/*
(B)
**
*/

_print_bDS($spells_data[0][0]);


/*
**
Output: (A)
**

Calefaction
0
name = Minor Shield of Magma
desc = Creates a field that damages anyone who attacks the target in 
melee.

id = 22
target = Realm
level = 1
damage_type = Matter

1
name = Shield of Magma
desc = Creates a field that damages anyone who attacks the target in 
melee.

id = 23
target = Realm
level = 5
damage_type = Matter

2
name = Greater Shield of Magma
desc = Creates a field that damages anyone who attacks the target in 
melee.

id = 24
target = Realm
level = 9
damage_type = Matter

...

**
Output: (B)
**

0
type = 1
data =
depth = 3



1
type = 2
tagname = level

attribs

   contains = 1
   depth = 3

children

0
   type = 1
   data = 1
   depth = 4







2
type = 1
data =
depth = 3



3
type = 2
tagname = range

attribs

   contains = 1
   depth = 3

children

0
   type = 1
   data = 1000
   depth = 4







4
type = 1
data =
depth = 3



5
type = 2
tagname = damage

attribs

   contains = 1
   depth = 3

children

0
   type = 1
   data = 0.7
   depth = 4







6
type = 1
data =
depth = 3



7
type = 2
tagname = damage_type

attribs

   contains = 1
   depth = 3

children

0
   type = 1
   data = Matter
   depth = 4


...

*/



function XML_tokenize($data,$file=False) {
   $p = new