php-general Digest 28 Apr 2010 06:39:57 -0000 Issue 6716

2010-04-28 Thread php-general-digest-help
php-general Digest 28 Apr 2010 06:39:57 - Issue 6716 Topics (messages 304680 through 304694): Re: Error handling strategies (db related) 304680 by: Gary . 304682 by: Andrew Ballard Re: php quiz script/tutorial 304681 by: Dotan Cohen 304683 by: Adam

[PHP] What is wrong with this code?

2010-04-28 Thread Gary .
class Pg_Error { private static $errors = array(INTEGRITY_CONST_UNIQUE = 'uniqueness constraint violated'); ... public static function getMessage($ec) { $text = ''; if (array_key_exists($ec, Pg_Error::$errors)) { $text =

Re: [PHP] What is wrong with this code?

2010-04-28 Thread Per Jessen
Gary . wrote: class Pg_Error { private static $errors = array(INTEGRITY_CONST_UNIQUE = 'uniqueness constraint violated'); ... public static function getMessage($ec) { $text = ''; if (array_key_exists($ec, Pg_Error::$errors)) {

Re: [PHP] What is wrong with this code?

2010-04-28 Thread Peter Lind
On 28 April 2010 08:39, Gary . php-gene...@garydjones.name wrote: class Pg_Error {    private static $errors =        array(INTEGRITY_CONST_UNIQUE = 'uniqueness constraint violated'); ...    public static function getMessage($ec)    {        $text = '';        if (array_key_exists($ec,

Re: [PHP] What is wrong with this code?

2010-04-28 Thread Gary .
Per Jessen wrote: Gary . wrote: Calling it, the array_key_exists call always returns false ... and I can't see what I've done wrong :( Might this be better: public static function getMessage($ec) { $text = ''; if (array_key_exists($ec, $errors)) {

Re: [PHP] What is wrong with this code?

2010-04-28 Thread Gary .
On 4/28/10, Jochem Maas wrote: Op 4/28/10 7:39 AM, Gary . schreef: class Pg_Error { const INTEGRITY_CONST_UNIQUE = '23505'; private static $errors = array(INTEGRITY_CONST_UNIQUE = 'uniqueness constraint violated'); ... public static function getMessage($ec) {

Re: [PHP] Error handling strategies (db related)

2010-04-28 Thread Pete Ford
On 27/04/10 16:37, tedd wrote: Error handling is almost an art form. More like a black art - voodoo perhaps... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] What is wrong with this code?

2010-04-28 Thread Gary .
On 4/28/10, Jochem Maas wrote: class Pg_Error { const INTEGRITY_CONST_UNIQUE = '23505'; this is a class constant private static $errors = array(INTEGRITY_CONST_UNIQUE = 'uniqueness constraint violated'); [...] unfortunately you cannot use a

Re: [PHP] auto indentation

2010-04-28 Thread Ashley Sheridan
On Tue, 2010-04-27 at 22:23 -0400, David McGlone wrote: On Tuesday 27 April 2010 16:55:45 Ashley Sheridan wrote: On Tue, 2010-04-27 at 16:33 -0400, David McGlone wrote: Hi everyone. I got a quickie LOL is there a way to auto indent code. I'm using Kate and I have it set so

Re: [PHP] auto indentation

2010-04-28 Thread Ashley Sheridan
On Tue, 2010-04-27 at 23:25 -0400, Paul M Foster wrote: On Tue, Apr 27, 2010 at 10:29:33PM -0400, David McGlone wrote: On Tuesday 27 April 2010 19:00:29 D. Dante Lorenso wrote: On 4/27/2010 3:55 PM, Ashley Sheridan wrote: On Tue, 2010-04-27 at 16:33 -0400, David McGlone wrote: Hi

Re: [PHP] What is wrong with this code?

2010-04-28 Thread Peter Lind
On 28 April 2010 10:57, Gary . php-gene...@garydjones.name wrote: On 4/28/10, Jochem Maas wrote:     class Pg_Error     {        const INTEGRITY_CONST_UNIQUE = '23505'; this is a class constant         private static $errors =             array(INTEGRITY_CONST_UNIQUE = 'uniqueness

[PHP] Irish PHP User Group meeting tonight

2010-04-28 Thread Ken Guest
Hi. Just to let any of ye know that might be interested, there's a php.ie meeting on tonight in Dublin - in the Longstone pub on Townsend Street starting at eight o'clock. It's located where the red diamond is on this map:

[PHP] Explanation of asynchronous postgres interface

2010-04-28 Thread Gary .
I asked something similar to this on the ph-db ml yesterday, but that list seems to be almost dead. The situation I have is that I am trying to get the postgres error code (as opposed to some error message - see my other posts to this list over the last day or so for the background to that). I

Re: [PHP] auto indentation

2010-04-28 Thread Gary .
On Tue, Apr 27, 2010 at 10:33 PM, David McGlone wrote: I'm using Kate Since you've already had a suggestion to switch to Eclipse, I'll say (+ emacs php-mode (+ '(define-key php-mode-map (kbd RET) 'newline-and-indent))) Or something like that. -- PHP General Mailing List

Re: [PHP] auto indentation

2010-04-28 Thread David McGlone
On Wednesday 28 April 2010 05:00:34 Ashley Sheridan wrote: On Tue, 2010-04-27 at 23:25 -0400, Paul M Foster wrote: On Tue, Apr 27, 2010 at 10:29:33PM -0400, David McGlone wrote: On Tuesday 27 April 2010 19:00:29 D. Dante Lorenso wrote: On 4/27/2010 3:55 PM, Ashley Sheridan wrote: On

Re: [PHP] What is wrong with this code?

2010-04-28 Thread Thijs Lensselink
Gary . wrote: class Pg_Error { private static $errors = array(INTEGRITY_CONST_UNIQUE = 'uniqueness constraint violated'); Shouldn't this be: array(self::INTEGRITY_CONST_UNIQUE = 'uniqueness constraint violated'); ... public static function getMessage($ec) {

[PHP] Two color rows in table inside while iteration

2010-04-28 Thread Juan Rodriguez Monti
Hello Guys, I would like to implement a two color row table for some queries that I'm doing. I use PHP to query a DB, then I use while to print all its results. I have a code pretty similar to this one : $results = Here the QUERY; echo html; echo head; echo 'link

Re: [PHP] What is wrong with this code?

2010-04-28 Thread Gary .
On 4/28/10, Thijs Lensselink wrote: Gary . wrote: class Pg_Error { private static $errors = array(INTEGRITY_CONST_UNIQUE = 'uniqueness constraint violated'); Shouldn't this be: array(self::INTEGRITY_CONST_UNIQUE = 'uniqueness constraint violated'); Yes, or something very like

Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Ashley Sheridan
On Wed, 2010-04-28 at 08:29 -0300, Juan Rodriguez Monti wrote: Hello Guys, I would like to implement a two color row table for some queries that I'm doing. I use PHP to query a DB, then I use while to print all its results. I have a code pretty similar to this one : $results = Here

RE: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Jay Blanchard
[snip] I just want to show you how I write the table. What I would like to know is what do you suggest to do a two color row format. [/snip] Before your table; $trColor = 0; Then during the loop; while(foo){ $tr = (0 == $trColor % 2)? #E8E8E8 : #FF; echo tr style=\background-color:.$tr.\;

Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Gary .
On 4/28/10, Juan Rodriguez Monti wrote: I would like to implement a two color row table for some queries that I'm doing. ... what do you suggest to do a two color row format. Well, I wouldn't mix the presentation and querying of the db in one place, but assuming that's just a simplified

Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Ali Asghar Toraby Parizy
It isn't good idea to use php to visualize your table. You can fetch you data by php and style them by java script. On Wed, Apr 28, 2010 at 3:59 PM, Juan Rodriguez Monti j...@rodriguezmonti.com.ar wrote: Hello Guys, I would like to implement a two color row table for some queries that I'm

Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Ashley Sheridan
On Wed, 2010-04-28 at 16:16 +0430, Ali Asghar Toraby Parizy wrote: It isn't good idea to use php to visualize your table. You can fetch you data by php and style them by java script. On Wed, Apr 28, 2010 at 3:59 PM, Juan Rodriguez Monti j...@rodriguezmonti.com.ar wrote: Hello Guys, I

Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Juan Rodriguez Monti
2010/4/28 Jay Blanchard jblanch...@pocket.com: [snip] I just want to show you how I write the table. What I would like to know is what do you suggest to do a two color row format. [/snip] Before your table; $trColor = 0; Then during the loop; while(foo){ $tr = (0 == $trColor % 2)?

Re: [PHP] What is wrong with this code?

2010-04-28 Thread Thijs Lensselink
Gary . wrote: On 4/28/10, Thijs Lensselink wrote: Gary . wrote: class Pg_Error { private static $errors = array(INTEGRITY_CONST_UNIQUE = 'uniqueness constraint violated'); Shouldn't this be: array(self::INTEGRITY_CONST_UNIQUE = 'uniqueness constraint violated');

RE: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Jay Blanchard
[snip] Before your table; $trColor = 0; Then during the loop; while(foo){ $tr = (0 == $trColor % 2)? #E8E8E8 : #FF; echo tr style=\background-color:.$tr.\; ... Replace the hex values with the colors you desire. Just one more question about this. I'm getting something like

Re: [PHP] What is wrong with this code?

2010-04-28 Thread Gary .
On Wed, Apr 28, 2010 at 2:17 PM, Thijs Lensselink wrote: Gary . wrote: On 4/28/10, Thijs Lensselink wrote: Gary . wrote: class Pg_Error {    private static $errors =        array(INTEGRITY_CONST_UNIQUE = 'uniqueness constraint violated'); Shouldn't this be:

Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Jochen Schultz
Like this? $color[0] = 'red'; $color[1] = 'blue'; for ($i=0;foo;$i++) { echo 'tr style:background-color:'.$color[$i%2]... regards Jochen Jay Blanchard schrieb: [snip] Before your table; $trColor = 0; Then during the loop; while(foo){ $tr = (0 == $trColor % 2)? #E8E8E8 : #FF; echo tr

Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Juan Rodriguez Monti
2010/4/28 Jay Blanchard jblanch...@pocket.com: [snip] Before your table; $trColor = 0; Then during the loop; while(foo){ $tr = (0 == $trColor % 2)? #E8E8E8 : #FF; echo tr style=\background-color:.$tr.\; ... Replace the hex values with the colors you desire. Just one more

Re: [PHP] Error handling strategies (db related)

2010-04-28 Thread viraj
On Tue, Apr 27, 2010 at 7:34 PM, Gary . php-gene...@garydjones.name wrote: On Tue, Apr 27, 2010 at 10:46 AM, Peter Lind wrote: On 27 April 2010 10:42, Gary . wrote: How do you guys handle errors during, say, db insertions. Let's say you have an ongoing transaction which fails on the n-th

Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Ali Asghar Toraby Parizy
I agree with you. in this simple example we can use php but we may need table with extra functionality and only client side scripts are reasonable and applicable. we can create multi color and clickable rows by php but we'll have greater server load. anyway that was only an propose;-) On Wed, Apr

Re: [PHP] auto indentation

2010-04-28 Thread Paul M Foster
On Wed, Apr 28, 2010 at 09:52:16AM +0100, Ashley Sheridan wrote: snip I set it to use tabs of 4 spaces wide and use c-style indenting. It doesn't automatically indent as I write, but I find it a good thing that an editor doesn't change anything I write, as that is where problems can occur!

Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Fernando
What about this: $color = even; while ($row = while condition )) { $color = ($color == even) ? odd : even; echo (tr class=\$color\); echo td$row[0]/tdtd$row[1]/td td$row[2]/tdtd$row[3]/tdtd$row[4]/td ; echo (/tr) } And have two classes in your style sheet that

Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Ashley Sheridan
On Wed, 2010-04-28 at 17:59 +0430, Ali Asghar Toraby Parizy wrote: I agree with you. in this simple example we can use php but we may need table with extra functionality and only client side scripts are reasonable and applicable. we can create multi color and clickable rows by php but we'll

Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Ashley Sheridan
On Wed, 2010-04-28 at 09:34 -0400, Fernando wrote: What about this: $color = even; while ($row = while condition )) { $color = ($color == even) ? odd : even; echo (tr class=\$color\); echo td$row[0]/tdtd$row[1]/td td$row[2]/tdtd$row[3]/tdtd$row[4]/td ;

Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Fernando
But then you need to differentiate the table, otherwise all your tables will have the same row formating no? This way you only apply the formating to those rows that need it. Fernando. On 28/04/2010 09:35, Ashley Sheridan wrote: On Wed, 2010-04-28 at 09:34 -0400, Fernando wrote: What

Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Ashley Sheridan
On Wed, 2010-04-28 at 09:46 -0400, Fernando wrote: But then you need to differentiate the table, otherwise all your tables will have the same row formating no? This way you only apply the formating to those rows that need it. Fernando. On 28/04/2010 09:35, Ashley Sheridan wrote: On

Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Juan Rodriguez Monti
2010/4/28 Fernando ferna...@ggtours.ca: What about this: $color = even; while ($row = while condition )) {       $color = ($color == even) ? odd : even;       echo (tr class=\$color\);       echo td$row[0]/tdtd$row[1]/td  td$row[2]/tdtd$row[3]/tdtd$row[4]/td  ;       echo (/tr) } And

RE: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Bob McConnell
From: Ashley Sheridan On Wed, 2010-04-28 at 09:46 -0400, Fernando wrote: But then you need to differentiate the table, otherwise all your tables will have the same row formating no? This way you only apply the formating to those rows that need it. Yes, but one would assume you'd be

Re: [PHP] Two color rows in table inside while iteration

2010-04-28 Thread Richard Quadling
On 28 April 2010 12:29, Juan Rodriguez Monti j...@rodriguezmonti.com.ar wrote: Hello Guys, I would like to implement a two color row table for some queries that I'm doing. I use PHP to query a DB, then I use while to print all its results. I have a code pretty similar to this one :  

Re: [PHP] Irish PHP User Group meeting tonight

2010-04-28 Thread Daniel Brown
On Wed, Apr 28, 2010 at 05:47, Ken Guest k...@linux.ie wrote: Hi. Just to let any of ye know that might be interested, there's a php.ie meeting on tonight in Dublin - in the Longstone pub on Townsend Street starting at eight o'clock. It's located where the red diamond is on this map:

Re: [PHP] Irish PHP User Group meeting tonight

2010-04-28 Thread Ken Guest
On Wed, Apr 28, 2010 at 3:38 PM, Daniel Brown danbr...@php.net wrote: On Wed, Apr 28, 2010 at 05:47, Ken Guest k...@linux.ie wrote: Hi. Just to let any of ye know that might be interested, there's a php.ie meeting on tonight in Dublin - in the Longstone pub on Townsend Street starting at

Re: [PHP] Irish PHP User Group meeting tonight

2010-04-28 Thread Daniel Brown
On Wed, Apr 28, 2010 at 11:28, Ken Guest k...@linux.ie wrote: that would be a handy idea ;-) Next time the mirrors update, that link will be included in the event details. Should be in under 90 minutes for the majority of the world. -- /Daniel P. Brown daniel.br...@parasane.net ||

[PHP] Security/Development Question

2010-04-28 Thread David Stoltz
Hi folks, This isn't really a PHP question per se, but could apply to any language... I have a public facing web server, which we have a software component that helps protect us from SQL Injection, and the like. We recently have added a very small web application that is vendor

Re: [PHP] Security/Development Question

2010-04-28 Thread Andre Polykanine
Hello David, I'm not a PHP god but I would never ever do such things.I can't even imagine what can be the reason of passing an SQL query through a form... -- With best regards from Ukraine, Andre Skype: Francophile; WlmMSN: arthaelon @ yandex.ru; Jabber: arthaelon @ jabber.org Yahoo! messenger:

Re: [PHP] Security/Development Question

2010-04-28 Thread Paul M Foster
On Wed, Apr 28, 2010 at 04:54:56PM -0400, David Stoltz wrote: Hi folks, This isn't really a PHP question per se, but could apply to any language... I have a public facing web server, which we have a software component that helps protect us from SQL Injection, and the like.

Re: [PHP] Security/Development Question

2010-04-28 Thread Robert Cummings
David Stoltz wrote: Hi folks, This isn't really a PHP question per se, but could apply to any language... I have a public facing web server, which we have a software component that helps protect us from SQL Injection, and the like. We recently have added a very small web application that is

Re: [PHP] Security/Development Question

2010-04-28 Thread Programming Guides
On Wed, Apr 28, 2010 at 4:02 PM, Andre Polykanine an...@oire.org wrote: Hello David, I'm not a PHP god but I would never ever do such things.I can't even imagine what can be the reason of passing an SQL query through a form... -- With best regards from Ukraine, Andre Skype: Francophile;

Re: [PHP] Security/Development Question

2010-04-28 Thread Karl DeSaulniers
Hi all, I am learning PHP and found this problem to be interesting. I personally would never do this myself. All the manuals I have read strictly prohibit this type of behavior. Wouldn't you just have them run the queries on their end and send you the results instead of the query itself?

Re: [PHP] CURL cannot connect to URL - IP address - after successful connection

2010-04-28 Thread ioan...@btinternet.com
I think the answer is: ISPs have a different range of addresses from host providers, so it is possible to block requests from host servers, so from scripts. John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] Re: Security/Development Question

2010-04-28 Thread Ross McKay
On Wed, 28 Apr 2010 16:54:56 -0400, David Stoltz wrote: [...] We recently have added a very small web application that is vendor supported. They said it's not working, so I investigated. I found that our software protection was blocking their pages because they are actually passing entire SQL

Re: [PHP] Re: Security/Development Question

2010-04-28 Thread Ashley Sheridan
On Thu, 2010-04-29 at 08:49 +1000, Ross McKay wrote: On Wed, 28 Apr 2010 16:54:56 -0400, David Stoltz wrote: [...] We recently have added a very small web application that is vendor supported. They said it's not working, so I investigated. I found that our software protection was blocking

RE: [PHP] CURL cannot connect to URL - IP address - after successful connection

2010-04-28 Thread Tommy Pham
-Original Message- From: ioan...@btinternet.com [mailto:ioan...@btinternet.com] Sent: Wednesday, April 28, 2010 7:03 AM To: 'PHP' Subject: Re: [PHP] CURL cannot connect to URL - IP address - after successful connection I think the answer is: ISPs have a different range of

[PHP] Malware Question

2010-04-28 Thread Ashley Sheridan
Hi all, This isn't exactly a PHP question, but I don't know anyone else with the collected smarts of this list. Basically, a site I built and am managing has been identified by Google as a source of malware. Now, I've been over the source code with a fine-toothed comb and found nothing, I've gone

Re: [PHP] Malware Question

2010-04-28 Thread Daniel Brown
On Wed, Apr 28, 2010 at 19:50, Ashley Sheridan a...@ashleysheridan.co.uk wrote: The Google webmaster tools tell me nothing more than 'Of the 2 pages we tested on the site over the past 90 days, 2 page(s) resulted in malicious software being downloaded and installed without user consent.' It

[PHP] Re: Malware Question

2010-04-28 Thread Ross McKay
On Thu, 29 Apr 2010 00:50:52 +0100, Ashley Sheridan wrote: This isn't exactly a PHP question, but I don't know anyone else with the collected smarts of this list. Basically, a site I built and am managing has been identified by Google as a source of malware. [...] Check the sites you link to. We