[PHP] Error handling strategies (db related)

2010-04-27 Thread Gary .
How do you guys handle errors during, say, db insertions.

Let's say you have an ongoing transaction which fails on the n-th
insert. Ok, you roll back the transaction, no problem. How do you then
inform the user? Just using the text from pg_result_error  or
something?

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



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

2010-04-27 Thread Peter Lind
On 27 April 2010 10:42, Gary . php-gene...@garydjones.name 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
 insert. Ok, you roll back the transaction, no problem. How do you then
 inform the user? Just using the text from pg_result_error  or
 something?


If it's a normal user, give them some info about what went wrong but
not the specific error returned. If it's an admin with dev knowledge
(i.e. you) then consider handing out the returned error as well.

Rule of thumb: aim to inform the user without confusing. There's
nothing worse than This didn't work, sorry - why didn't it work??
Was it my fault? Can I get it to work somehow?

Regards
Peter


-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype

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



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

2010-04-27 Thread Michiel Sikma
On 27 April 2010 10:42, Gary . php-gene...@garydjones.name 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
 insert. Ok, you roll back the transaction, no problem. How do you then
 inform the user? Just using the text from pg_result_error  or
 something?


Developers are usually lazy about error reporting because it's much easier
to just return the error code. Some parsing is very useful to the user,
since overtly technical information is just confusing.

The error should never be something that the user himself can avoid (since
you're supposed to have error checking and handling before the user
submits), so your error should make this clear to him. It helps to let him
know that the developer has been notified and that he can try again later.

Michiel


[PHP] special character problem

2010-04-27 Thread saeed ahmed
hello friends,

I have used

preg_replace('/[^0-9a-zа\~...@\$\%\^\*\(\)\;\,\.\'\/\_]/i', ' ',$match);

for remove the special characters.  its work fine. but the problem I want to
remove special characters from this kind of sentence

///

#: quot;'Amor''' é fogo que arde sem se ver,''
#: ''é ferida que dói, e não se sente,''
#: ''é um contentamento descontente,''
#: ''é dor que desatina sem doer.''quot;
#:: ''- Camões''


///

its remove all special character including é, ã, õ, which I do not want to.
I want to remove special character except these three. please suggest me...

-
Regards
Saeed Ahmed
http://saeed05.wordpress.com
-


[PHP] Weird while issue

2010-04-27 Thread Juan Rodriguez Monti
Hi guys,
I have some issues with while.

I have an HTML Form, that uses GET to process its contents. Then
there's a PHP Script that receives the data, and evaluates the fields.

So, in some instance of the code, I do something like :

if (empty($a) AND empty($b)) {

echo something;
echo something;
echo something;

while ($row = sqlite_fetch_array($results,SQLITE_BOTH)) {

And here I print some echo's to print an HTML's Table with the results
of the while.
echo Something more;
echo etc;

}
} elseif (empty($c) AND empty($d)) {

Here there is another elseif similar to the first one explained above.

}

I have four or five elseif's that analizes the fields of the HTML's
Form and then the PHP's Code do things depending of the combinations
of fields submited and so on.

The problem is that if I want to add an echo saying Come Back to
Index to index.html, I'm not able to show it after the while's
iteration.

The PHP code prints the table with its results taken from SQlite
perfectly. Also it evaluates all the conditions flawessly. However, If
I add a link to come back with the text Go to Index after the while
and before the } close to the next elseif, PHP prints it in the wrong
ubication.

I got something like:

TITLE

*** Go to Index ***

While results. This is the table containing all the results of the
SQlite's Query.

If I move the echo to other part of the block, I receive so many
echo's as iterations the while do ( this is logical ). However I don't
understand why the echo is printed above the while even when I put it
after the while and out of the while's block.

Thanks a lot!.

Juan

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



Re: [PHP] What's your game? (X-PHP)

2010-04-27 Thread Richard Quadling
On 26 April 2010 19:54, Williams, Dewey willi...@uncc.edu wrote:
 The only online games I play are Guild Wars and - now - Dungeons and
 Dragons Online (FREE!).  I haven't played vgaplanets in ages - too few
 servers to get a decent game. Not certain I can even install my original
 3.5 inch disk anymore!

 Dewey Williams

 -Original Message-
 From: tedd [mailto:t...@sperling.com]
 Sent: Sunday, April 25, 2010 9:16 AM
 To: php-general@lists.php.net
 Subject: [PHP] What's your game? (X-PHP)

 Hi gang:

 Considering we recently had several people mention what games they
 play, it might be interesting to see what everyone plays.

 As for me, I currently play Modern Warfare 2 on XBOX. It's the most
 recent in a long line of war games (i.e., Call of Duty, Ghost Recon,
 etc.).

 My gamer tag is special tedd

 What's your game?

 Cheers,

 tedd


 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com

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



I also like Ico and Shadow Of The Colossus, both on PS2.

I bought the PS2 because of Ico.

I'll probably buy a PS3 because of the next game they are making in
the same style.




-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Weird while issue

2010-04-27 Thread Peter Lind
On 27 April 2010 14:36, Juan Rodriguez Monti j...@rodriguezmonti.com.ar wrote:
 Hi guys,
 I have some issues with while.

 I have an HTML Form, that uses GET to process its contents. Then
 there's a PHP Script that receives the data, and evaluates the fields.

 So, in some instance of the code, I do something like :

 if (empty($a) AND empty($b)) {

 echo something;
 echo something;
 echo something;

 while ($row = sqlite_fetch_array($results,SQLITE_BOTH)) {

 And here I print some echo's to print an HTML's Table with the results
 of the while.
 echo Something more;
 echo etc;

            }
 } elseif (empty($c) AND empty($d)) {

 Here there is another elseif similar to the first one explained above.

 }

 I have four or five elseif's that analizes the fields of the HTML's
 Form and then the PHP's Code do things depending of the combinations
 of fields submited and so on.

 The problem is that if I want to add an echo saying Come Back to
 Index to index.html, I'm not able to show it after the while's
 iteration.

 The PHP code prints the table with its results taken from SQlite
 perfectly. Also it evaluates all the conditions flawessly. However, If
 I add a link to come back with the text Go to Index after the while
 and before the } close to the next elseif, PHP prints it in the wrong
 ubication.

 I got something like:

 TITLE

 *** Go to Index ***

 While results. This is the table containing all the results of the
 SQlite's Query.

 If I move the echo to other part of the block, I receive so many
 echo's as iterations the while do ( this is logical ). However I don't
 understand why the echo is printed above the while even when I put it
 after the while and out of the while's block.


Check your html for broken html table code.

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype

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



Re: [PHP] What's your game? (X-PHP)

2010-04-27 Thread Programming Guides
On Tue, Apr 27, 2010 at 7:37 AM, Richard Quadling
rquadl...@googlemail.comwrote:

 On 26 April 2010 19:54, Williams, Dewey willi...@uncc.edu wrote:
  The only online games I play are Guild Wars and - now - Dungeons and
  Dragons Online (FREE!).  I haven't played vgaplanets in ages - too few
  servers to get a decent game. Not certain I can even install my original
  3.5 inch disk anymore!
 
  Dewey Williams
 
  -Original Message-
  From: tedd [mailto:t...@sperling.com]
  Sent: Sunday, April 25, 2010 9:16 AM
  To: php-general@lists.php.net
  Subject: [PHP] What's your game? (X-PHP)
 
  Hi gang:
 
  Considering we recently had several people mention what games they
  play, it might be interesting to see what everyone plays.
 
  As for me, I currently play Modern Warfare 2 on XBOX. It's the most
  recent in a long line of war games (i.e., Call of Duty, Ghost Recon,
  etc.).
 
  My gamer tag is special tedd
 
  What's your game?
 
  Cheers,
 
  tedd
 
 
  --
  ---
  http://sperling.com  http://ancientstones.com  http://earthstones.com
 
  --
  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
 
 

 I also like Ico and Shadow Of The Colossus, both on PS2.

 I bought the PS2 because of Ico.

 I'll probably buy a PS3 because of the next game they are making in
 the same style.




 --
 -
 Richard Quadling
 Standing on the shoulders of some very clever giants!
 EE : http://www.experts-exchange.com/M_248814.html
 EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
 Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
 ZOPA : http://uk.zopa.com/member/RQuadling

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


I've played and still play StarCraft: Brood War a lot. StarCraft 2 is now
available for pre-order and the beta is active. I'm looking forward to it
but I'm not looking forward to how much time I'll sink into it :)

-- 
Viktor
http://programming-guides.com


Re: [PHP] Weird while issue

2010-04-27 Thread Juan Rodriguez Monti
2010/4/27 Peter Lind peter.e.l...@gmail.com:
 On 27 April 2010 14:36, Juan Rodriguez Monti j...@rodriguezmonti.com.ar 
 wrote:
 Hi guys,
 I have some issues with while.

 I have an HTML Form, that uses GET to process its contents. Then
 there's a PHP Script that receives the data, and evaluates the fields.

 So, in some instance of the code, I do something like :

 if (empty($a) AND empty($b)) {

 echo something;
 echo something;
 echo something;

 while ($row = sqlite_fetch_array($results,SQLITE_BOTH)) {

 And here I print some echo's to print an HTML's Table with the results
 of the while.
 echo Something more;
 echo etc;

            }
 } elseif (empty($c) AND empty($d)) {

 Here there is another elseif similar to the first one explained above.

 }

 I have four or five elseif's that analizes the fields of the HTML's
 Form and then the PHP's Code do things depending of the combinations
 of fields submited and so on.

 The problem is that if I want to add an echo saying Come Back to
 Index to index.html, I'm not able to show it after the while's
 iteration.

 The PHP code prints the table with its results taken from SQlite
 perfectly. Also it evaluates all the conditions flawessly. However, If
 I add a link to come back with the text Go to Index after the while
 and before the } close to the next elseif, PHP prints it in the wrong
 ubication.

 I got something like:

 TITLE

 *** Go to Index ***

 While results. This is the table containing all the results of the
 SQlite's Query.

 If I move the echo to other part of the block, I receive so many
 echo's as iterations the while do ( this is logical ). However I don't
 understand why the echo is printed above the while even when I put it
 after the while and out of the while's block.


 Check your html for broken html table code.

 Regards
 Peter

Hi Peter,
That was the problem. Solved!.

Thanks,
Juan

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



Re: [PHP] What's your game? (X-PHP)

2010-04-27 Thread Dan Joseph
On Tue, Apr 27, 2010 at 9:24 AM, Programming Guides 
programming.gui...@gmail.com wrote:

 I've played and still play StarCraft: Brood War a lot. StarCraft 2 is now
 available for pre-order and the beta is active. I'm looking forward to it
 but I'm not looking forward to how much time I'll sink into it :)

 --
 Viktor
 http://programming-guides.com



I am amazed at how long Starcraft has lasted, and how popular it still is.
Is the MMORPG version Starcraft 2?  Or is that yet another one?


-- 
-Dan Joseph

www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.  Promo
Code NEWTHINGS for 10% off initial order

http://www.facebook.com/canishosting
http://www.facebook.com/originalpoetry


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

2010-04-27 Thread Paul M Foster
On Tue, Apr 27, 2010 at 10:42:03AM +0200, 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
 insert. Ok, you roll back the transaction, no problem. How do you then
 inform the user? Just using the text from pg_result_error  or
 something?

I use trigger_error() and stop execution at that point. I give the user
an error that basically says, Talk to the admin/programmer. And I send
the programmer a message containing a trace of what occurred. The theory
is that, all things being equal, such an error should never occur and
there is no user recovery. If the user properly entered the data they
were asked for, then the transaction should go through without incident.
If something prevents the transaction from going through, it's likely a
coding problem and up to the programmer or admin to repair.

Paul

-- 
Paul M. Foster

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



Re: [PHP] What's your game? (X-PHP)

2010-04-27 Thread Programming Guides
On Tue, Apr 27, 2010 at 8:27 AM, Dan Joseph dmjos...@gmail.com wrote:

 On Tue, Apr 27, 2010 at 9:24 AM, Programming Guides 
 programming.gui...@gmail.com wrote:

  I've played and still play StarCraft: Brood War a lot. StarCraft 2 is now
  available for pre-order and the beta is active. I'm looking forward to it
  but I'm not looking forward to how much time I'll sink into it :)
 
  --
  Viktor
  http://programming-guides.com
 


 I am amazed at how long Starcraft has lasted, and how popular it still is.
 Is the MMORPG version Starcraft 2?  Or is that yet another one?


 --
 -Dan Joseph

 www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.  Promo
 Code NEWTHINGS for 10% off initial order

 http://www.facebook.com/canishosting
 http://www.facebook.com/originalpoetry


It's not an MMO; it's still an RTS. It's just new graphics, new interface,
some rebalancing and a continuation of the storyline.

-- 
http://programming-guides.com


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

2010-04-27 Thread Peter Lind
On 27 April 2010 15:36, Paul M Foster pa...@quillandmouse.com wrote:
 On Tue, Apr 27, 2010 at 10:42:03AM +0200, 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
 insert. Ok, you roll back the transaction, no problem. How do you then
 inform the user? Just using the text from pg_result_error  or
 something?

 I use trigger_error() and stop execution at that point. I give the user
 an error that basically says, Talk to the admin/programmer. And I send
 the programmer a message containing a trace of what occurred. The theory
 is that, all things being equal, such an error should never occur and
 there is no user recovery. If the user properly entered the data they
 were asked for, then the transaction should go through without incident.
 If something prevents the transaction from going through, it's likely a
 coding problem and up to the programmer or admin to repair.


Fair reasoning, but it amounts to throwing a bucket of cold water in
the face of your user. If I was looking at an error like that, I'd get
mighty annoyed with the software, and after a while would definitely
look for alternatives. Whether or not there's a coding problem, you
have to look at the situation from the point of the user: a complete
failure with no information is like a BSOD/TSOD ... and we all know
the effect they have on a user.

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype

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



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

2010-04-27 Thread Gary .
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
 insert. Ok, you roll back the transaction, no problem. How do you then
 inform the user? Just using the text from pg_result_error  or
 something?


 If it's a normal user, give them some info about what went wrong but
 not the specific error returned.

Yeah. I know :( Originally I couldn't find a nice way of translating
between db errors and user errors. The only interface to the db
errors that I could find was the error messages returned from
pg_last_error. Yes, I could have used an array translating between the
the strings returned by pg_last_error or whatever, but *gag* it would
not only have made the code look horrible but would also have been
susceptible to changes in the error messages returned by the db
interface. In the end I changed tack slightly and used pg_send_* and
pg_result_error_field to get a short code I could use as a reference
into an array.

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



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

2010-04-27 Thread Paul M Foster
On Tue, Apr 27, 2010 at 03:41:04PM +0200, Peter Lind wrote:

 On 27 April 2010 15:36, Paul M Foster pa...@quillandmouse.com wrote:
  On Tue, Apr 27, 2010 at 10:42:03AM +0200, 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
  insert. Ok, you roll back the transaction, no problem. How do you then
  inform the user? Just using the text from pg_result_error  or
  something?
 
  I use trigger_error() and stop execution at that point. I give the user
  an error that basically says, Talk to the admin/programmer. And I send
  the programmer a message containing a trace of what occurred. The theory
  is that, all things being equal, such an error should never occur and
  there is no user recovery. If the user properly entered the data they
  were asked for, then the transaction should go through without incident.
  If something prevents the transaction from going through, it's likely a
  coding problem and up to the programmer or admin to repair.
 
 
 Fair reasoning, but it amounts to throwing a bucket of cold water in
 the face of your user. If I was looking at an error like that, I'd get
 mighty annoyed with the software, and after a while would definitely
 look for alternatives. Whether or not there's a coding problem, you
 have to look at the situation from the point of the user: a complete
 failure with no information is like a BSOD/TSOD ... and we all know
 the effect they have on a user.

I assume (1) that I've vetted the user data and given them the option to
repair it if it's faulty; (2) beyond the beta phase, this type of error
should not happen. If it does, it's a coding problem. Given that the
user can do *nothing* about this and it *is* a coding problem, what
would you tell the user?

If I was the user, I'd be cranky as well. But if I were a smart user,
I'd realize that the programmer made a mistake and put the
responsibility firmly on him. And expect him to fix it pronto.

Paul

-- 
Paul M. Foster

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



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

2010-04-27 Thread Peter Lind
On 27 April 2010 16:07, Paul M Foster pa...@quillandmouse.com wrote:
 On Tue, Apr 27, 2010 at 03:41:04PM +0200, Peter Lind wrote:

 On 27 April 2010 15:36, Paul M Foster pa...@quillandmouse.com wrote:
  On Tue, Apr 27, 2010 at 10:42:03AM +0200, 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
  insert. Ok, you roll back the transaction, no problem. How do you then
  inform the user? Just using the text from pg_result_error  or
  something?
 
  I use trigger_error() and stop execution at that point. I give the user
  an error that basically says, Talk to the admin/programmer. And I send
  the programmer a message containing a trace of what occurred. The theory
  is that, all things being equal, such an error should never occur and
  there is no user recovery. If the user properly entered the data they
  were asked for, then the transaction should go through without incident.
  If something prevents the transaction from going through, it's likely a
  coding problem and up to the programmer or admin to repair.
 

 Fair reasoning, but it amounts to throwing a bucket of cold water in
 the face of your user. If I was looking at an error like that, I'd get
 mighty annoyed with the software, and after a while would definitely
 look for alternatives. Whether or not there's a coding problem, you
 have to look at the situation from the point of the user: a complete
 failure with no information is like a BSOD/TSOD ... and we all know
 the effect they have on a user.

 I assume (1) that I've vetted the user data and given them the option to
 repair it if it's faulty; (2) beyond the beta phase, this type of error
 should not happen. If it does, it's a coding problem. Given that the
 user can do *nothing* about this and it *is* a coding problem, what
 would you tell the user?

Sorry, but there was a problem inserting the data into the database.
The developers have been notified about this error and will hopefully
have it fixed very soon. We apologize for the inconvenience.

At the very least, something along those lines.

 If I was the user, I'd be cranky as well. But if I were a smart user,
 I'd realize that the programmer made a mistake and put the
 responsibility firmly on him. And expect him to fix it pronto.

If only the world consisted of smart users ... I think, however, that
we're generally closer to the opposite. And no, I don't hate users -
I've just seen too many people do things that were very far removed
from smart.

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype

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



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

2010-04-27 Thread Paul M Foster
On Tue, Apr 27, 2010 at 04:13:20PM +0200, Peter Lind wrote:

 On 27 April 2010 16:07, Paul M Foster pa...@quillandmouse.com wrote:
  On Tue, Apr 27, 2010 at 03:41:04PM +0200, Peter Lind wrote:
 
  On 27 April 2010 15:36, Paul M Foster pa...@quillandmouse.com wrote:
   On Tue, Apr 27, 2010 at 10:42:03AM +0200, 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
   insert. Ok, you roll back the transaction, no problem. How do you then
   inform the user? Just using the text from pg_result_error  or
   something?
  
   I use trigger_error() and stop execution at that point. I give the user
   an error that basically says, Talk to the admin/programmer. And I send
   the programmer a message containing a trace of what occurred. The theory
   is that, all things being equal, such an error should never occur and
   there is no user recovery. If the user properly entered the data they
   were asked for, then the transaction should go through without incident.
   If something prevents the transaction from going through, it's likely a
   coding problem and up to the programmer or admin to repair.
  
 
  Fair reasoning, but it amounts to throwing a bucket of cold water in
  the face of your user. If I was looking at an error like that, I'd get
  mighty annoyed with the software, and after a while would definitely
  look for alternatives. Whether or not there's a coding problem, you
  have to look at the situation from the point of the user: a complete
  failure with no information is like a BSOD/TSOD ... and we all know
  the effect they have on a user.
 
  I assume (1) that I've vetted the user data and given them the option to
  repair it if it's faulty; (2) beyond the beta phase, this type of error
  should not happen. If it does, it's a coding problem. Given that the
  user can do *nothing* about this and it *is* a coding problem, what
  would you tell the user?
 
 Sorry, but there was a problem inserting the data into the database.
 The developers have been notified about this error and will hopefully
 have it fixed very soon. We apologize for the inconvenience.
 
 At the very least, something along those lines.

Well of course. No reason to slap the user in the face. I agree. But in
the end, this is about the same as saying, Talk to the programmer,
just a nicer way of saying it.

 
  If I was the user, I'd be cranky as well. But if I were a smart user,
  I'd realize that the programmer made a mistake and put the
  responsibility firmly on him. And expect him to fix it pronto.
 
 If only the world consisted of smart users ... I think, however, that
 we're generally closer to the opposite. And no, I don't hate users -
 I've just seen too many people do things that were very far removed
 from smart.

Unfortunately, true. Sometimes I think computer users should be required
to take a course in using a computer before being allowed behind the
keyboard.

Paul

-- 
Paul M. Foster

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



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

2010-04-27 Thread Peter Lind
On 27 April 2010 16:24, Paul M Foster pa...@quillandmouse.com wrote:
 On Tue, Apr 27, 2010 at 04:13:20PM +0200, Peter Lind wrote:

 On 27 April 2010 16:07, Paul M Foster pa...@quillandmouse.com wrote:
  On Tue, Apr 27, 2010 at 03:41:04PM +0200, Peter Lind wrote:
 
  On 27 April 2010 15:36, Paul M Foster pa...@quillandmouse.com wrote:
   On Tue, Apr 27, 2010 at 10:42:03AM +0200, 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
   insert. Ok, you roll back the transaction, no problem. How do you then
   inform the user? Just using the text from pg_result_error  or
   something?
  
   I use trigger_error() and stop execution at that point. I give the user
   an error that basically says, Talk to the admin/programmer. And I send
   the programmer a message containing a trace of what occurred. The theory
   is that, all things being equal, such an error should never occur and
   there is no user recovery. If the user properly entered the data they
   were asked for, then the transaction should go through without incident.
   If something prevents the transaction from going through, it's likely a
   coding problem and up to the programmer or admin to repair.
  
 
  Fair reasoning, but it amounts to throwing a bucket of cold water in
  the face of your user. If I was looking at an error like that, I'd get
  mighty annoyed with the software, and after a while would definitely
  look for alternatives. Whether or not there's a coding problem, you
  have to look at the situation from the point of the user: a complete
  failure with no information is like a BSOD/TSOD ... and we all know
  the effect they have on a user.
 
  I assume (1) that I've vetted the user data and given them the option to
  repair it if it's faulty; (2) beyond the beta phase, this type of error
  should not happen. If it does, it's a coding problem. Given that the
  user can do *nothing* about this and it *is* a coding problem, what
  would you tell the user?

 Sorry, but there was a problem inserting the data into the database.
 The developers have been notified about this error and will hopefully
 have it fixed very soon. We apologize for the inconvenience.

 At the very least, something along those lines.

 Well of course. No reason to slap the user in the face. I agree. But in
 the end, this is about the same as saying, Talk to the programmer,
 just a nicer way of saying it.

Of course, it's just a question of degree. If the user can't correct
the error, there's only one person that can: the programmer. Question
is what you tell the user in that situation.


  If I was the user, I'd be cranky as well. But if I were a smart user,
  I'd realize that the programmer made a mistake and put the
  responsibility firmly on him. And expect him to fix it pronto.

 If only the world consisted of smart users ... I think, however, that
 we're generally closer to the opposite. And no, I don't hate users -
 I've just seen too many people do things that were very far removed
 from smart.

 Unfortunately, true. Sometimes I think computer users should be required
 to take a course in using a computer before being allowed behind the
 keyboard.


While I love to rant at stupid users, the truth is probably that
programmers are the ones who should take courses in how users think.
In the end, if I fail to understand my users, it doesn't matter how
great my program is: they'll still fail to use it. Anyway, those are
just truisms :) Nothing new under the sun.

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype

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



[PHP] finding out datasets in a certain distance of a zip code

2010-04-27 Thread Merlin Morgenstern

Hi there,

I am trying to find mysql db entries inside a tabel with the help of php 
that are in the distance of a certain amount of kilometers from a given 
zip code.


Unfortunatelly something must be wrong, as I do not get the desired 
results. Has anybody experience with that?


Here is the code I wrote:

$plz = '79279';
$distance = 1000;

###
# find geo data for this zip code
$stmt =
SELECT
lat,
lang
FROM
test.zip
WHERE
zip = '$plz'
;
$row=db_get_row2($stmt);
$breite = deg2rad($row-lat);
$laenge = deg2rad($row-lang);
###

if ($breite){ // only if results
###
# search for the members
$stmt = 
SELECT SQL_CALC_FOUND_ROWS
cl.ID,
g.city,
g.area_1 AS quarter,
g.* ,
IFNULL( (
ACOS( (
SIN( $breite ) * SIN( RADIANS( lat ) ) ) + ( COS( $breite ) * COS( 
RADIANS( lat ) ) * COS( RADIANS( lang ) - $laenge ) ) ) *6371

), 0
) AS e
FROM
test.zip g,
test.cl cl
WHERE
IFNULL( (
ACOS( (
SIN( $breite ) * SIN( RADIANS( lat ) ) ) + ( COS( $breite ) * COS( 
RADIANS( lat ) ) * COS( RADIANS( lang ) - $laenge ) ) ) *6371

), 0
)  $distance
AND g.id = cl.zip_id
GROUP BY cl.ID  
ORDER BY
e ASC
;
$result = execute_stmt($stmt, $link);
while ($row = mysql_fetch_object($result)){
$entfernung_km  = round(($row-e*1.4),2);
echo 'cl: '.$row-cl_id.' '.$entfernung_km.'br';
}
$num_results = db_numrows($result);
###

} // end if results

Thank you for any help!

Merlin

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



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

2010-04-27 Thread Nathan Rixham
Peter Lind wrote:
 On 27 April 2010 16:24, Paul M Foster pa...@quillandmouse.com wrote:
 On Tue, Apr 27, 2010 at 04:13:20PM +0200, Peter Lind wrote:

 On 27 April 2010 16:07, Paul M Foster pa...@quillandmouse.com wrote:
 On Tue, Apr 27, 2010 at 03:41:04PM +0200, Peter Lind wrote:

 On 27 April 2010 15:36, Paul M Foster pa...@quillandmouse.com wrote:
 On Tue, Apr 27, 2010 at 10:42:03AM +0200, 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
 insert. Ok, you roll back the transaction, no problem. How do you then
 inform the user? Just using the text from pg_result_error  or
 something?
 I use trigger_error() and stop execution at that point. I give the user
 an error that basically says, Talk to the admin/programmer. And I send
 the programmer a message containing a trace of what occurred. The theory
 is that, all things being equal, such an error should never occur and
 there is no user recovery. If the user properly entered the data they
 were asked for, then the transaction should go through without incident.
 If something prevents the transaction from going through, it's likely a
 coding problem and up to the programmer or admin to repair.

 Fair reasoning, but it amounts to throwing a bucket of cold water in
 the face of your user. If I was looking at an error like that, I'd get
 mighty annoyed with the software, and after a while would definitely
 look for alternatives. Whether or not there's a coding problem, you
 have to look at the situation from the point of the user: a complete
 failure with no information is like a BSOD/TSOD ... and we all know
 the effect they have on a user.
 I assume (1) that I've vetted the user data and given them the option to
 repair it if it's faulty; (2) beyond the beta phase, this type of error
 should not happen. If it does, it's a coding problem. Given that the
 user can do *nothing* about this and it *is* a coding problem, what
 would you tell the user?
 Sorry, but there was a problem inserting the data into the database.
 The developers have been notified about this error and will hopefully
 have it fixed very soon. We apologize for the inconvenience.

 At the very least, something along those lines.
 Well of course. No reason to slap the user in the face. I agree. But in
 the end, this is about the same as saying, Talk to the programmer,
 just a nicer way of saying it.
 
 Of course, it's just a question of degree. If the user can't correct
 the error, there's only one person that can: the programmer. Question
 is what you tell the user in that situation.
 
 If I was the user, I'd be cranky as well. But if I were a smart user,
 I'd realize that the programmer made a mistake and put the
 responsibility firmly on him. And expect him to fix it pronto.
 If only the world consisted of smart users ... I think, however, that
 we're generally closer to the opposite. And no, I don't hate users -
 I've just seen too many people do things that were very far removed
 from smart.
 Unfortunately, true. Sometimes I think computer users should be required
 to take a course in using a computer before being allowed behind the
 keyboard.

 
 While I love to rant at stupid users, the truth is probably that
 programmers are the ones who should take courses in how users think.
 In the end, if I fail to understand my users, it doesn't matter how
 great my program is: they'll still fail to use it. Anyway, those are
 just truisms :) Nothing new under the sun.

I'm still shocked you guys are still writing code that has errors in it,
what's worse is you know about the errors, and instead of fixing them
you're just telling the user about it!

:p

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



[PHP] Re: finding out datasets in a certain distance of a zip code

2010-04-27 Thread Nathan Rixham
Merlin Morgenstern wrote:
 Hi there,
 
 I am trying to find mysql db entries inside a tabel with the help of php
 that are in the distance of a certain amount of kilometers from a given
 zip code.
 
 Unfortunatelly something must be wrong, as I do not get the desired
 results. Has anybody experience with that?
 
 Here is the code I wrote:
 
 $plz = '79279';
 $distance = 1000;
 
 ###
 # find geo data for this zip code
 $stmt =
 SELECT
 lat,
 lang
 FROM
 test.zip
 WHERE
 zip = '$plz'
 ;
 $row=db_get_row2($stmt);
 $breite = deg2rad($row-lat);
 $laenge = deg2rad($row-lang);
 ###
 
 if ($breite){ // only if results
 ###
 # search for the members
 $stmt = 
 SELECT SQL_CALC_FOUND_ROWS
 cl.ID,
 g.city,
 g.area_1 AS quarter,
 g.* ,
 IFNULL( (
 ACOS( (
 SIN( $breite ) * SIN( RADIANS( lat ) ) ) + ( COS(
 $breite ) * COS( RADIANS( lat ) ) * COS( RADIANS( lang ) - $laenge ) ) )
 *6371
 ), 0
 ) AS e
 FROM
 test.zip g,
 test.cl cl
 WHERE
 IFNULL( (
 ACOS( (
 SIN( $breite ) * SIN( RADIANS( lat ) ) ) + ( COS(
 $breite ) * COS( RADIANS( lat ) ) * COS( RADIANS( lang ) - $laenge ) ) )
 *6371
 ), 0
 )  $distance
 AND g.id = cl.zip_id
 GROUP BY cl.ID   
 ORDER BY
 e ASC
 ;
 $result = execute_stmt($stmt, $link);
 while ($row = mysql_fetch_object($result)){
 $entfernung_km = round(($row-e*1.4),2);
 echo 'cl: '.$row-cl_id.' '.$entfernung_km.'br';
 }
 $num_results = db_numrows($result);
 ###
 
 } // end if results
 
 Thank you for any help!
 
 Merlin

1: You really could do with using the mysql spatial extensions
http://dev.mysql.com/doc/refman/5.0/en/spatial-extensions.html

2: here's an old old post to this list that may help you
http://coding.derkeiler.com/Archive/PHP/php.general/2008-09/msg00531.html

Best,

Nathan

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



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

2010-04-27 Thread Teus Benschop
 I'm still shocked you guys are still writing code that has errors in it,
 what's worse is you know about the errors, and instead of fixing them
 you're just telling the user about it!
 

The point here is that we, programmers, know that we write code with
bugs in it. We are realistic about it, that is, we know that perfect
code does not exist, and that there are bugs in it. So what we care
about is to bring this reality to the users in a gracious manner. And
the other thing is that if for example a database is down, that is not
our fault, it is an external error, but this error should be brought to
the user as well. Teus.


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



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

2010-04-27 Thread tedd

At 9:36 AM -0400 4/27/10, Paul M Foster wrote:

On Tue, Apr 27, 2010 at 10:42:03AM +0200, 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
 insert. Ok, you roll back the transaction, no problem. How do you then
 inform the user? Just using the text from pg_result_error  or
 something?


I use trigger_error() and stop execution at that point. I give the user
an error that basically says, Talk to the admin/programmer. And I send
the programmer a message containing a trace of what occurred. The theory
is that, all things being equal, such an error should never occur and
there is no user recovery. If the user properly entered the data they
were asked for, then the transaction should go through without incident.
If something prevents the transaction from going through, it's likely a
coding problem and up to the programmer or admin to repair.

Paul



+1

I do something similar with the accounts I want to monitor.

For example, when I access the database during development, I use 
code similar to this --


// --- script
$sql = SELECT * FROM users WHERE user_id = $uid ;
$result = mysql_query($sql) or die(report($query,__LINE__ ,__FILE__));
// --

-- and then a report function similar to this --

// -- functions
function report($query, $line, $file)
   {
   echo($query . 'br /' .$line . 'br /' . $file . 'br /' . 
mysql_error());

   }
// --

This provides me with information as to what happened and where.

When the project goes live (out of development) then I replace the 
report function with code that can send me an email telling me what 
happened (to what domain) as well as an explanation to the user 
(screen display and sometimes even email) and sometimes an email is 
sent to the client (i.e., the user's credit card was denied for xxx 
reason trying to purchase product xxx at this date).


Note, all my error reporting functions are located in a single 
function script that is included with every script that has access to 
the database. That way I can turn on/off error reporting and make 
alterations as to how to handle errors in one file. The difference 
between development and live is a simply a change in one script.


Error handling is almost an art form.

Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



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

2010-04-27 Thread Nathan Rixham
Teus Benschop wrote:
 I'm still shocked you guys are still writing code that has errors in it,
 what's worse is you know about the errors, and instead of fixing them
 you're just telling the user about it!

 
 The point here is that we, programmers, know that we write code with
 bugs in it. We are realistic about it, that is, we know that perfect
 code does not exist, and that there are bugs in it. So what we care
 about is to bring this reality to the users in a gracious manner. And
 the other thing is that if for example a database is down, that is not
 our fault, it is an external error, but this error should be brought to
 the user as well. Teus.
 

had hoped the addition of a (now stripped) :p emote would ensure taking
the above as a joke tbh  ;)

regardless, might I add that exceptions or errors mapped through to the
appropriate HTTP status code and a friendly site specific error document
may be a good way to proceed.

A good example of friendly error documents can be seen at most of the
major sites around the web that we all frequent (or are at least aware of).

Further, these friendly documents make it clear that the error is a
server / application error and that no action the user takes will fix
the error.

Best,

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



RE: [PHP] What's your game? (X-PHP)

2010-04-27 Thread Tommy Pham
 -Original Message-
 From: Programming Guides [mailto:programming.gui...@gmail.com]
 Sent: Tuesday, April 27, 2010 6:35 AM
 To: Dan Joseph
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] What's your game? (X-PHP)
 
 On Tue, Apr 27, 2010 at 8:27 AM, Dan Joseph dmjos...@gmail.com wrote:
 
  On Tue, Apr 27, 2010 at 9:24 AM, Programming Guides 
  programming.gui...@gmail.com wrote:
 
   I've played and still play StarCraft: Brood War a lot. StarCraft 2
   is now available for pre-order and the beta is active. I'm looking
   forward to it but I'm not looking forward to how much time I'll sink
   into it :)
  
   --
   Viktor
   http://programming-guides.com
  
 
 
  I am amazed at how long Starcraft has lasted, and how popular it still
is.
  Is the MMORPG version Starcraft 2?  Or is that yet another one?
 
 
  --
  -Dan Joseph
 
  www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.
  Promo Code NEWTHINGS for 10% off initial order
 
  http://www.facebook.com/canishosting
  http://www.facebook.com/originalpoetry
 
 
 It's not an MMO; it's still an RTS. It's just new graphics, new interface,
some
 rebalancing and a continuation of the storyline.
 
 --
 http://programming-guides.com

From the previews/trailers I've seen, there is no 4th race that was in the
final (bonus ?) mission in the Starcraft+Broodwar.  In that mission, there
was an experiment done on all 3 races.  IIRC, the 4th race is supposed to be
a combination of all the good from other 3 races.


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



RE: [PHP] Re: finding out datasets in a certain distance of a zip code

2010-04-27 Thread Tommy Pham
Hi Nathan,

WOW!!  4GB when rar'ed.  That must too you a while to compile that
information.

Regards,
Tommy


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



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

2010-04-27 Thread tedd

At 4:13 PM +0200 4/27/10, Peter Lind wrote:

If only the world consisted of smart users ... I think, however, that
we're generally closer to the opposite. And no, I don't hate users -
I've just seen too many people do things that were very far removed
from smart.

Regards
Peter


Peter et al:

Smart is a relative term. I have one account where the majority of 
users are PhD's -- and they indeed have the smarts and the 
sheepskins to prove it.


You would be surprised as to how many of those forget their logons 
and insist that they did not enter their logons as they were 
recorded. For example, I had one user (i.e., fictitious Mary Smith) 
who said that marysmith was not her logon because she always uses 
msmith for all her logons -- but that was what was recorded in the 
database.


I tried to explain to her that the database doesn't make this stuff 
up, for example how would the script know to use marysmith for her 
logon if she had not provided it? But somehow it was the script's 
fault for not knowing she always uses msmith. Keep in mind these 
are people with PhD's. I have many other stories.


As I see it, one of the problems we face as developers is confronting 
user's egos. They have an image of themselves and our scripts can 
threaten that image by making them feel ignorant. We have to deal 
with that in a way that informs them, but doesn't demean them in any 
fashion.


Here's a real world example -- over 20 years ago a company made an 
electronic hand-held chess game.


While the game was successful, the company received a considerable 
amount of repairs, way over what they had expected. They wanted to 
find out why and after an investigation they found that their 
software made the computer's chess-moves TOO quickly. So, they place 
a time delay into the software so that it would look to the user 
like the computer was thinking about its moves. That time-delay 
solved the problem.


Apparently, some end-users got pissed when they thought the computer 
could so easily beat them. But, if the computer took more time to 
beat them, then that was more acceptable and the end-users were less 
inclined to throw the game into a wall.


So with respect to software engineering, how users view what's going 
on is important.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



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

2010-04-27 Thread tedd

At 10:24 AM -0400 4/27/10, Paul M Foster wrote:

Unfortunately, true. Sometimes I think computer users should be required
to take a course in using a computer before being allowed behind the
keyboard.

Paul


Yeah, like I believe that everyone should do through at least one 
divorce before getting married.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



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

2010-04-27 Thread Ashley Sheridan
On Tue, 2010-04-27 at 12:12 -0400, tedd wrote:

 At 4:13 PM +0200 4/27/10, Peter Lind wrote:
 If only the world consisted of smart users ... I think, however, that
 we're generally closer to the opposite. And no, I don't hate users -
 I've just seen too many people do things that were very far removed
 from smart.
 
 Regards
 Peter
 
 Peter et al:
 
 Smart is a relative term. I have one account where the majority of 
 users are PhD's -- and they indeed have the smarts and the 
 sheepskins to prove it.
 
 You would be surprised as to how many of those forget their logons 
 and insist that they did not enter their logons as they were 
 recorded. For example, I had one user (i.e., fictitious Mary Smith) 
 who said that marysmith was not her logon because she always uses 
 msmith for all her logons -- but that was what was recorded in the 
 database.
 
 I tried to explain to her that the database doesn't make this stuff 
 up, for example how would the script know to use marysmith for her 
 logon if she had not provided it? But somehow it was the script's 
 fault for not knowing she always uses msmith. Keep in mind these 
 are people with PhD's. I have many other stories.
 
 As I see it, one of the problems we face as developers is confronting 
 user's egos. They have an image of themselves and our scripts can 
 threaten that image by making them feel ignorant. We have to deal 
 with that in a way that informs them, but doesn't demean them in any 
 fashion.
 
 Here's a real world example -- over 20 years ago a company made an 
 electronic hand-held chess game.
 
 While the game was successful, the company received a considerable 
 amount of repairs, way over what they had expected. They wanted to 
 find out why and after an investigation they found that their 
 software made the computer's chess-moves TOO quickly. So, they place 
 a time delay into the software so that it would look to the user 
 like the computer was thinking about its moves. That time-delay 
 solved the problem.
 
 Apparently, some end-users got pissed when they thought the computer 
 could so easily beat them. But, if the computer took more time to 
 beat them, then that was more acceptable and the end-users were less 
 inclined to throw the game into a wall.
 
 So with respect to software engineering, how users view what's going 
 on is important.
 
 Cheers,
 
 tedd
 
 -- 
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com
 


Sounds like you've got a few stories that would a lot of people happy
were you to share them on the DailyWTF ;)

Thanks,
Ash
http://www.ashleysheridan.co.uk




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

2010-04-27 Thread tedd

At 4:31 PM +0200 4/27/10, Peter Lind wrote:

While I love to rant at stupid users, the truth is probably that
programmers are the ones who should take courses in how users think.
In the end, if I fail to understand my users, it doesn't matter how
great my program is: they'll still fail to use it. Anyway, those are
just truisms :) Nothing new under the sun.

Regards
Peter



Peter:

You're right on. I just read three books on the subject:

1. Don't Make Me Think by Steve Krug.

This is a somewhat dated book, but his perspective is right-on and 
is the basis for understanding usability.


2. Neuro Web Design bu Susan M. Weinschenk.

The theory behind why people do what they do is explained in great 
detail in this book. It makes a great book to read regardless of if 
you're trying to sell something on the net or elsewhere. However, 
this book is focused on selling things to people via the net.


3. Rocket Surgery Made Easy by Steve Krug.

This is the second book in Steve's How to do it yourself in 
usability studies. It will give you exactly what you need to do to 
set up inexpensive usability studies. Usability studies are important 
in software and web design.


If developers (and clients) read those books, we would have less 
problems dealing with users.


Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



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

2010-04-27 Thread tedd

At 4:23 PM +0100 4/27/10, Nathan Rixham wrote:


I'm still shocked you guys are still writing code that has errors in it,
what's worse is you know about the errors, and instead of fixing them
you're just telling the user about it!

:p


Here's my code that doesn't contain errors:

?php

?

Cheers,

ted

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



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

2010-04-27 Thread Peter Lind
On 27 April 2010 18:21, tedd tedd.sperl...@gmail.com wrote:
 At 4:31 PM +0200 4/27/10, Peter Lind wrote:

 While I love to rant at stupid users, the truth is probably that
 programmers are the ones who should take courses in how users think.
 In the end, if I fail to understand my users, it doesn't matter how
 great my program is: they'll still fail to use it. Anyway, those are
 just truisms :) Nothing new under the sun.

 Regards
 Peter


 Peter:

 You're right on. I just read three books on the subject:

 1. Don't Make Me Think by Steve Krug.

 This is a somewhat dated book, but his perspective is right-on and is the
 basis for understanding usability.

+1. Great book that is.

 2. Neuro Web Design bu Susan M. Weinschenk.

 The theory behind why people do what they do is explained in great detail in
 this book. It makes a great book to read regardless of if you're trying to
 sell something on the net or elsewhere. However, this book is focused on
 selling things to people via the net.

Will have to look at that, sounds interesting.

 3. Rocket Surgery Made Easy by Steve Krug.

 This is the second book in Steve's How to do it yourself in usability
 studies. It will give you exactly what you need to do to set up inexpensive
 usability studies. Usability studies are important in software and web
 design.

 If developers (and clients) read those books, we would have less problems
 dealing with users.


Haven't read his second, guess I should :) Thanks for the recommendations.

Regards
Peter


-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype

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



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

2010-04-27 Thread tedd

At 5:09 PM +0100 4/27/10, Ashley Sheridan wrote:




Sounds like you've got a few stories that would a lot of people 
happy were you to share them on the DailyWTF ;)


Thanks,
Ash


Ash:

Sharing them here is more direct and meaningful to what we do, but I 
will investigate what you suggest.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Re: What's your game? (X-PHP)

2010-04-27 Thread David Harkness
Left 4 Dead 2, by far my favorite game on the PC, is my current fixation. I
enjoy Battlefield 2: Bad Company but tend to get annoyed having to face
opponents 5-10 x my level. You can find me as Captain Cujo on both games.

On Sun, Apr 25, 2010 at 10:37 AM, Nathan Rixham nrix...@gmail.com wrote:

 however, there is one
 caveat which is Civilization 4 (which i haven't played for about 2 years
 now)


If you'd like to enjoy Civ4 again, might I humbly suggest you grab The BUG
Mod (BTS Unaltered Gameplay) if you have the Beyond the Sword expansion
pack. It doesn't alter any game rules as the name suggests, but it vastly
improves the user interface. BAT includes BUG plus a bunch of nice terrain
and civilization-specific graphics to make it very pretty if your video card
is more modern. I'm EmperorFool, the lead developer on the BUG team.

There are other quality game-changing mods for Civ4 such as Legends of
Revolution, History of Three Kingdoms, Dune Wars, and Rise of Mankind that
add more spice to the game.


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

2010-04-27 Thread Paul M Foster
On Tue, Apr 27, 2010 at 12:12:31PM -0400, tedd wrote:

 At 4:13 PM +0200 4/27/10, Peter Lind wrote:
 If only the world consisted of smart users ... I think, however, that
 we're generally closer to the opposite. And no, I don't hate users -
 I've just seen too many people do things that were very far removed
 from smart.

 Regards
 Peter

 Peter et al:

 Smart is a relative term. I have one account where the majority of
 users are PhD's -- and they indeed have the smarts and the
 sheepskins to prove it.

 You would be surprised as to how many of those forget their logons
 and insist that they did not enter their logons as they were
 recorded. For example, I had one user (i.e., fictitious Mary Smith)
 who said that marysmith was not her logon because she always uses
 msmith for all her logons -- but that was what was recorded in the
 database.

 I tried to explain to her that the database doesn't make this stuff
 up, for example how would the script know to use marysmith for her
 logon if she had not provided it? But somehow it was the script's
 fault for not knowing she always uses msmith. Keep in mind these
 are people with PhD's. I have many other stories.

There's the problem right there. PhD egos. Seen it before.

In my company, we deal with a lot of doctors. For us, that means
chiropractors, dentists, veterinarians, optomotrists and the like. Who
we don't deal with is doctors of the MD variety. They are way too
arrogant, and their staffs typically back that claim up. The few times
we've dealt with them, it's always been a disaster.

Paul

-- 
Paul M. Foster

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



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

2010-04-27 Thread Tommy Pham
 At 10:24 AM -0400 4/27/10, Paul M Foster wrote:
Unfortunately, true. Sometimes I think computer users should be
required to take a course in using a computer before being allowed
behind the keyboard.

Paul

I came across a term long ago amidst my readings: PEBKAC

Problem
Exists
Between
Keyboard
And
Chair

Regards,
Tommy


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



Re: [PHP] php quiz script/tutorial

2010-04-27 Thread tedd

At 4:12 PM +0100 4/26/10, Paul Jinks wrote:

I'm considering my options for making quizzes mostly multiple choice
type of thing, but also 'filling in the gaps'. This is in support of
educational materials I'm working on. So far I've looked at Flash and
javascript but have concerns about accessibility for both of these.

Does anyone have any experience of writing quizzes with php and if so,
can you recommend any resources to get me started?

TIA

Paul


Paul:

I have written surveys/quizzes, but have not found a lot of resources for it.

I use javascript usually to handle minor user things, such as Please 
answer the question before moving on or Rank these items in order 
of importance, or other such immediate demands of the user, but 
still the user input not to be trusted. IOW, you still have to scrub 
everything.


While I could use Flash, I choose not for it would simply make my 
work-load harder.


Quizzes and such are just a long cascade of forms.

I usually use one form and populate it with questions (content and 
type) from a database. Then when the user submits their data, I then 
save the answer as a independent record with ties to the test, 
question and responder. The database design takes some thought to 
set up correctly.


In the end, there is not really anything that hard about this, it's 
just collecting information from the user via a form and storing that 
information in a database.


Cheers,

tedd



--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



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

2010-04-27 Thread Gary .
On 4/27/10, tedd wrote:
 At 4:23 PM +0100 4/27/10, Nathan Rixham wrote:

I'm still shocked you guys are still writing code that has errors in it,
what's worse is you know about the errors, and instead of fixing them
you're just telling the user about it!

:p

 Here's my code that doesn't contain errors:

 ?php

 ?

Wow! What license are you applying to that? Can I re-use it without
fear or being sued for copyright infringement?

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



Re: [PHP] php quiz script/tutorial

2010-04-27 Thread Dotan Cohen
On 26 April 2010 18:12, Paul Jinks p...@pauljinks.co.uk wrote:
 I'm considering my options for making quizzes mostly multiple choice
 type of thing, but also 'filling in the gaps'. This is in support of
 educational materials I'm working on. So far I've looked at Flash and
 javascript but have concerns about accessibility for both of these.

 Does anyone have any experience of writing quizzes with php and if so,
 can you recommend any resources to get me started?

 TIA

 Paul

HTML has a form element with radio buttons, text fields, and more. Use that.


-- 
Dotan Cohen

http://bido.com
http://what-is-what.com

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



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

2010-04-27 Thread Andrew Ballard
On Tue, Apr 27, 2010 at 12:23 PM, tedd tedd.sperl...@gmail.com wrote:
 At 4:23 PM +0100 4/27/10, Nathan Rixham wrote:

 I'm still shocked you guys are still writing code that has errors in it,
 what's worse is you know about the errors, and instead of fixing them
 you're just telling the user about it!

 :p

 Here's my code that doesn't contain errors:

 ?php

 ?

 Cheers,

 ted

 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Watch out for that new warning message:

br /
bWarning/b:  Deadbeat script. Your code does not do anything
useful in bteddscript.php/b on line b1/bbr /


:-)

Andrew

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



Re: [PHP] php quiz script/tutorial

2010-04-27 Thread Adam Richardson
On Tue, Apr 27, 2010 at 12:55 PM, tedd tedd.sperl...@gmail.com wrote:

 At 4:12 PM +0100 4/26/10, Paul Jinks wrote:

 I'm considering my options for making quizzes mostly multiple choice
 type of thing, but also 'filling in the gaps'. This is in support of
 educational materials I'm working on. So far I've looked at Flash and
 javascript but have concerns about accessibility for both of these.

 Does anyone have any experience of writing quizzes with php and if so,
 can you recommend any resources to get me started?

 TIA

 Paul


 Paul:

 I have written surveys/quizzes, but have not found a lot of resources for
 it.

 I use javascript usually to handle minor user things, such as Please
 answer the question before moving on or Rank these items in order of
 importance, or other such immediate demands of the user, but still the user
 input not to be trusted. IOW, you still have to scrub everything.

 While I could use Flash, I choose not for it would simply make my work-load
 harder.

 Quizzes and such are just a long cascade of forms.

 I usually use one form and populate it with questions (content and type)
 from a database. Then when the user submits their data, I then save the
 answer as a independent record with ties to the test, question and
 responder. The database design takes some thought to set up correctly.

 In the end, there is not really anything that hard about this, it's just
 collecting information from the user via a form and storing that information
 in a database.

 Cheers,

 tedd



 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com


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


If you were going to use Flash, I'd go the Flex route as it makes short work
of this kind of view.

Ted already mentioned the DB route using PHP, but you could also use PHP to
set up an XML schema that represents quizes (e.g., quizquestion
id=1textWill this work?/textoptionsoptionYes this
will./optionoptionNo it won't./option/options/questionemail
respon...@msu.edu/email/quiz)  With this type of scheme (one in which
the html form is automatically built up from an XML document), you could
just have the results emailed to an account as individual TSV file
attachments (that's why I included the email tag in the example above),
making it easy for anyone to tally the results after dragging the documents
into Excel.

Last, you can also leverage existing technologies.  In addition to quiz
generators available online, Google Docs allows you to create forms that
store responses in spreadsheets (Create New - Form).  You can choose from a
variety of response types (text, multiple choice, etc.), and it works quite
well.

Just tossing out ideas ;)

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


[PHP] auto indentation

2010-04-27 Thread David McGlone
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 the 
tab is only 4 spaces, but I was wondering if there was an easier way than to 
have to hit the tab key 1x then 2x then 3x then 2x then 1x to create nice laid 
out code like this:

-
 -
  -
   -
-
   -
  -
 -
-

or:

function() {

function here
}

-- 
Blessings,
David M.

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



Re: [PHP] auto indentation

2010-04-27 Thread shiplu
There is a command indent in your kde.
Check the manual

Shiplu Mokaddim
My talks, http://talk.cmyweb.net
Follow me, http://twitter.com/shiplu
SUST Programmers, http://groups.google.com/group/p2psust
Innovation distinguishes bet ... ... (ask Steve Jobs the rest)

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



Re: [PHP] auto indentation

2010-04-27 Thread Ashley Sheridan
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 the 
 tab is only 4 spaces, but I was wondering if there was an easier way than to 
 have to hit the tab key 1x then 2x then 3x then 2x then 1x to create nice 
 laid 
 out code like this:
 
 -
  -
   -
-
 -
-
   -
  -
 -
 
 or:
 
 function() {
 
   function here
 }
 
 -- 
 Blessings,
 David M.
 


I use Kate too, and the indentation changed slightly in KDE 4. In the
configure dialogue window, go down to the Editing section in the left
menu and set the number of spaces to use in both the General tab (under
Tabulators) and the Indentation tab (under Indentation Properties. If
they are both different then you have to hit the tab key 4 times in
order for your spaces to be replaced by a tab character.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] auto indentation

2010-04-27 Thread D. Dante Lorenso

On 4/27/2010 3:55 PM, 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 the
tab is only 4 spaces, but I was wondering if there was an easier way than to
have to hit the tab key 1x then 2x then 3x then 2x then 1x to create nice laid
out code like this:


I use PHPEclipse for this.  It's not Eclipse with PDT, it's PHP Eclipse:

http://www.phpeclipse.com/

The code formatter built into that formats my code when I hit 
Ctrl+Shift+F.  No other code formatter works as well for what I've 
found.  Many formatters just indent, this one will reformatt by putting 
brackets up or down, and reindent all the code to fit my coding standards.


Project is getting a little old, though and doesn't yet support PHP 5.3 
syntax, but it's still the best I've found.


-- Dante

--
D. Dante Lorenso
da...@lorenso.com
972-333-4139

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



Re: [PHP] auto indentation

2010-04-27 Thread Programming Guides
On Tue, Apr 27, 2010 at 6:00 PM, D. Dante Lorenso da...@lorenso.com wrote:

 On 4/27/2010 3:55 PM, 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
 the
 tab is only 4 spaces, but I was wondering if there was an easier way than
 to
 have to hit the tab key 1x then 2x then 3x then 2x then 1x to create nice
 laid
 out code like this:


 I use PHPEclipse for this.  It's not Eclipse with PDT, it's PHP Eclipse:

 http://www.phpeclipse.com/

 The code formatter built into that formats my code when I hit Ctrl+Shift+F.
  No other code formatter works as well for what I've found.  Many formatters
 just indent, this one will reformatt by putting brackets up or down, and
 reindent all the code to fit my coding standards.

 Project is getting a little old, though and doesn't yet support PHP 5.3
 syntax, but it's still the best I've found.

 -- Dante

 --
 D. Dante Lorenso
 da...@lorenso.com
 972-333-4139


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


vim ftw:

1. select the piece of code you want to indent (or select all with ggVG)
2. Hit =
3. profit!

-- 
http://programming-guides.com


Re: [PHP] auto indentation

2010-04-27 Thread Paul M Foster
On Tue, Apr 27, 2010 at 08:52:09PM -0500, Programming Guides wrote:

 On Tue, Apr 27, 2010 at 6:00 PM, D. Dante Lorenso da...@lorenso.com wrote:
 
  On 4/27/2010 3:55 PM, 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
  the
  tab is only 4 spaces, but I was wondering if there was an easier way than
  to
  have to hit the tab key 1x then 2x then 3x then 2x then 1x to create nice
  laid
  out code like this:
 
 

snip

 vim ftw:
 
 1. select the piece of code you want to indent (or select all with ggVG)
 2. Hit =
 3. profit!

+1 for vim

I use a limited number of g commands, like gg, G and gwap, but I use
them rotely; I've never understood the variations. Can you point me to
some sort of tutorial on these?

Paul


-- 
Paul M. Foster

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



Re: [PHP] auto indentation

2010-04-27 Thread David McGlone
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
  the tab is only 4 spaces, but I was wondering if there was an easier way
  than to have to hit the tab key 1x then 2x then 3x then 2x then 1x to
  create nice laid out code like this:
 
  -
   -
-
 -
  -
 -
-
   -
  -
 
  or:
 
  function() {
 
  function here
  }
 
 I use Kate too, and the indentation changed slightly in KDE 4. In the
 configure dialogue window, go down to the Editing section in the left
 menu and set the number of spaces to use in both the General tab (under
 Tabulators) and the Indentation tab (under Indentation Properties. If
 they are both different then you have to hit the tab key 4 times in
 order for your spaces to be replaced by a tab character.

Thanks Ash. What is your preferences  for indenting code? Do you have it set 
so you don't have to hit the tab key at all? I set my numbers in kate to 4 
what about you?

-- 
Blessings,
David M.

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



Re: [PHP] auto indentation

2010-04-27 Thread David McGlone
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 everyone.
  I got a quickie LOL
  is there a way to auto indent code. I'm using Kate and I have it set so
  the tab is only 4 spaces, but I was wondering if there was an easier way
  than to have to hit the tab key 1x then 2x then 3x then 2x then 1x to
  create nice laid out code like this:
 
 I use PHPEclipse for this.  It's not Eclipse with PDT, it's PHP Eclipse:
 
 http://www.phpeclipse.com/
 
 The code formatter built into that formats my code when I hit
 Ctrl+Shift+F.  No other code formatter works as well for what I've
 found.  Many formatters just indent, this one will reformatt by putting
 brackets up or down, and reindent all the code to fit my coding standards.
 
 Project is getting a little old, though and doesn't yet support PHP 5.3
 syntax, but it's still the best I've found.

I haven't tried this one. I am just so stuck on Kate. I've tried a ton of 
editors and Kate is simply the best one for me hands down.

I'll check out php Eclipse. Never know I may be impressed with it.

After about 10 or more years of using KDE, I am have been running Gnome for 
about a year now, but I always always install Kontact and kate.

-- 
Blessings,
David M.

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



Re: [PHP] auto indentation

2010-04-27 Thread Programming Guides
On Tue, Apr 27, 2010 at 9:15 PM, Paul M Foster pa...@quillandmouse.comwrote:

 On Tue, Apr 27, 2010 at 08:52:09PM -0500, Programming Guides wrote:

  On Tue, Apr 27, 2010 at 6:00 PM, D. Dante Lorenso da...@lorenso.com
 wrote:
 
   On 4/27/2010 3:55 PM, 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
   the
   tab is only 4 spaces, but I was wondering if there was an easier way
 than
   to
   have to hit the tab key 1x then 2x then 3x then 2x then 1x to create
 nice
   laid
   out code like this:
  
  

 snip

  vim ftw:
 
  1. select the piece of code you want to indent (or select all with
 ggVG)
  2. Hit =
  3. profit!

 +1 for vim

 I use a limited number of g commands, like gg, G and gwap, but I use
 them rotely; I've never understood the variations. Can you point me to
 some sort of tutorial on these?

 Paul


 --
 Paul M. Foster

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


I gotta say I dont understand the g commands very well either. They dont
seem to have much in common, and I, like yourself know a handful that I am
comfortable using. In any case, this cheat sheet has several g commands
(although I commonly use some that are not listed):

http://www.fprintf.net/vimCheatSheet.html

-- 
Viktor
http://programming-guides.com


Re: [PHP] auto indentation

2010-04-27 Thread Paul M Foster
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 everyone.
   I got a quickie LOL
   is there a way to auto indent code. I'm using Kate and I have it set so
   the tab is only 4 spaces, but I was wondering if there was an easier way
   than to have to hit the tab key 1x then 2x then 3x then 2x then 1x to
   create nice laid out code like this:
 
  I use PHPEclipse for this.  It's not Eclipse with PDT, it's PHP Eclipse:
 
  http://www.phpeclipse.com/
 
  The code formatter built into that formats my code when I hit
  Ctrl+Shift+F.  No other code formatter works as well for what I've
  found.  Many formatters just indent, this one will reformatt by putting
  brackets up or down, and reindent all the code to fit my coding standards.
 
  Project is getting a little old, though and doesn't yet support PHP 5.3
  syntax, but it's still the best I've found.
 
 I haven't tried this one. I am just so stuck on Kate. I've tried a ton of
 editors and Kate is simply the best one for me hands down.

I have to say, back in the day when I used a GUI editor, Kate was the
best I found. 

Paul

-- 
Paul M. Foster

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