php-general Digest 12 Sep 2009 20:37:25 -0000 Issue 6336

Topics (messages 297946 through 297956):

Re: [Formaldehyde] The Most Basic Ajax - PHP Error Debugger
        297946 by: Andrea Giammarchi
        297947 by: Andrea Giammarchi
        297949 by: tedd
        297955 by: Jim Lucas
        297956 by: J DeBord

Re: get an object property
        297948 by: Tom Worster
        297951 by: Tom Worster
        297953 by: Tom Worster
        297954 by: Ralph Deffke

Re: Creating alphanumeric id for a table
        297950 by: tedd

Re: Reading files in PHP 5.3.0
        297952 by: tedd

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Ajax interactions usually produces different results, 'cause an Ajax 
interaction that returns an entire document does not make much sense.
Formaldehyde is for Ajax interaction, which "in my case" I always catch via 
headers checks or special parameters.

Formaldehyde is client agnostic, FireBUG or FirePHP could or could not be 
there, but providing both server and client code, we do not have to worry about 
anything.

Finally, even if called manually, the page will have a status 500 and the error 
will be still readable, being it the first JSON encoded key but obviously, for 
manual interactions it is extremely simple to spot the error, if any, since PHP 
clearly shows it in the page, if there are no other debuggers.

The stuff about application/json does not make much sense to me, and FireBUG 
shows automatically things passed via eval, it is not about the response type 
(also because it could simply be a security problem)

Again, Formaldehyde, is client side agnostic, so if we have IE, rather than 
Firefox, or Safari, Chrome, Opera, Formaldehyde will work, helping with 
unmanaged PHP errors (or managed one, if we manually throw an exception or 
trigger an error)

Regards

> From: [email protected]
> Date: Sat, 12 Sep 2009 11:39:43 +0530
> To: [email protected]
> CC: [email protected]
> Subject: Re: [PHP] RE: [Formaldehyde] The Most Basic Ajax - PHP Error Debugger
> 
> I dont think I understood you completely..
> 
> Javascript debugger: Something you use to debug javascript. but
> Formaldehyde dosent make any seance if xhr object is not used.
> PHP Debugger: We cant use Formaldehyde to debug errors in every single
> PHP script. I am talking about pages called directly via the browsers
> URL bar. FirePHP on the other hand can be used with all PHP scripts.
> AJAX Debugger: I think the example given in Formaldehyde Google code
> page fits this category. If not may be you can give an example ?
> 
> @Andera May be you should consider using application/json as the
> content type instead of text/plain.
> The Response text given by  Formaldehyde cannot be understood manually
> (for example if I use jQuery.load()).
> Had the content type been application/json firebug parses it by default
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

_________________________________________________________________
More than messages–check out the rest of the Windows Live™.
http://www.microsoft.com/windows/windowslive/

--- End Message ---
--- Begin Message ---
as margin note, the project page changed name, hopefully less ambiguous:

Formandehyde - Zero Config Ajax Based PHP Error Debugger

Regards

_________________________________________________________________
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx

--- End Message ---
--- Begin Message ---
At 12:20 AM +0200 9/12/09, Andrea Giammarchi wrote:
 > Date: Fri, 11 Sep 2009 12:37:30 -0400
 To: [email protected]; [email protected]
 From: [email protected]
Subject: RE: [PHP] RE: [Formaldehyde] The Most Basic Ajax - PHP Error Debugger
 The only
 things that may go wrong are in the data I am sending to the ajax
 routine AND/OR the way my php scripts deal with the data when they
 receive it.

Formaldehyde tells you in the client debugger what was wrong in the php code indeed.
Did you actually read the page before you replied?

No, I didn't read the page before I replied. YOU asked a question and I replied (read the thread) -- I'm sorry that I did. I'll refrain from doing it again.

tedd

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

--- End Message ---
--- Begin Message ---
Andrea Giammarchi wrote:
something I cannot find in any other library or framework.

This should tell you something then...

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

--- End Message ---
--- Begin Message ---
On Sat, Sep 12, 2009 at 8:47 PM, Jim Lucas <[email protected]> wrote:

> Andrea Giammarchi wrote:
>
>> something I cannot find in any other library or framework.
>>
>
> This should tell you something then...
>
> If something like Formandehyde isn't useful, then why is Charles so popular
(note: popular from my perspective. I wouldn't dare think that it is popular
with anyone on this list unless they expressly told me so)
http://www.charlesproxy.com/ . I can't say anything about the responses
Andrea has gotten without sounding rude and likely starting an internet
fight, so I won't say anything. Except for this. Tedd, the ajax example you
linked to does not need any debugging, that is for sure.


> --
> Jim Lucas
>
>   "Some men are born to greatness, some achieve greatness,
>       and some have greatness thrust upon them."
>
> Twelfth Night, Act II, Scene V
>    by William Shakespeare
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On 9/12/09 12:31 AM, "Paul M Foster" <[email protected]> wrote:

> On Fri, Sep 11, 2009 at 07:31:01PM -0400, Tom Worster wrote:
> 
>> if i have an expression that evaluates to an object, the return value from a
>> function, say, and i only want the value of one of the objects properties,
>> is there a tidy way to get it without setting another variable?
>> 
>> to illustrate, here's something that doesn't work, but it would be
>> convenient if it did:
>> 
>> $o = array( (object) array('a'=>1), (object) array('a'=>2) );
>> 
>> if ( end($o)->a > 1 ) {  // can't use -> like this!
>> ...
>> }
>> 
> 
> You should use print_r() or var_dump() to investigate what happens when
> you try to cast an array into an object. I myself don't know what would
> happen. Also, what's allowed and what effects are produced could depend
> heavily on the version of PHP you're running. Version 4 != 5 != 5.3 in
> this respect.

i did that long ago when i was looking for php's object literal syntax. i
didn't find one. we discussed it here more recently and consensus appeared
to be that casting an array was the most convenient workaround.



--- End Message ---
--- Begin Message ---
On 9/12/09 1:32 AM, "Lars Torben Wilson" <[email protected]> wrote:

> Tom Worster wrote:
>> if i have an expression that evaluates to an object, the return value from a
>> function, say, and i only want the value of one of the objects properties,
>> is there a tidy way to get it without setting another variable?
>> 
>> to illustrate, here's something that doesn't work, but it would be
>> convenient if it did:
>> 
>> $o = array( (object) array('a'=>1), (object) array('a'=>2) );
>> 
>> if ( end($o)->a > 1 ) {  // can't use -> like this!
>> ...
>> }
> 
> What version of PHP are you using? Your example should work.
> 
> Torben

5.2.9.

what version does it work in?



--- End Message ---
--- Begin Message ---
On 9/12/09 9:50 AM, "Tom Worster" <[email protected]> wrote:

> On 9/12/09 1:32 AM, "Lars Torben Wilson" <[email protected]> wrote:
> 
>> Tom Worster wrote:
>>> if i have an expression that evaluates to an object, the return value from a
>>> function, say, and i only want the value of one of the objects properties,
>>> is there a tidy way to get it without setting another variable?
>>> 
>>> to illustrate, here's something that doesn't work, but it would be
>>> convenient if it did:
>>> 
>>> $o = array( (object) array('a'=>1), (object) array('a'=>2) );
>>> 
>>> if ( end($o)->a > 1 ) {  // can't use -> like this!
>>> ...
>>> }
>> 
>> What version of PHP are you using? Your example should work.
>> 
>> Torben
> 
> 5.2.9.
> 
> what version does it work in?

i shamefully beg your pardon, lars. i was sure i tested the example but it's
clear to me now i either didn't or i made a mistake. end($o)->a IS php
syntax! so -> may follow a function (or method, i guess) call.

but let me give you a more different example:

$a and $b are normally both objects, each with various members including a
prop q, but sometimes $a is false. i want the q of $a if $a isn't false,
otherwise that of $b.

($a ? $a : $b)->q   // is not php, afaik

before you suggest one, i know there are simple workarounds.

but mine is a theoretical question about syntax, not a practical one. i'm
exploring php's syntactic constraints on the -> operator in contrast to,
say, the + or . operators. and in contrast to other languages.

for example, the . in js seems more generally allowed than -> (or, for that
matter, []) in php. programmers (especially using jquery) are familiar with
using . after an expression that evaluates to an object, e.g.

<body>
<p id="thepara" class="top x23 indent">My x class number is
    <span id="num"></span></p>
<div id="mandatory" style="border: solid red 1px"></div>
<script type="text/javascript">
document.getElementById('num').innerText =
  ( ( document.getElementById('optional')
      || document.getElementById('mandatory')
    ).appendChild(document.getElementById('thepara'))
    .className.match(/x(\d+)/) || [0,'absent']
  )[1]
</script>
</body>

which shows . after objects, method calls and expressions (as well as the []
operator applied to an expression).

do we just live without in phpville or am i missing something?


and while i'm at it, and using my original error, how come...

function o() { return (object) array('q'=>7); }
echo o()->q;  // is ok syntax, but

function a() { return array('q'=>5); }
echo a()['q'];  // isn't?




--- End Message ---
--- Begin Message ---
> echo a()['q'];  // isn't?

because this is simply not valid syntax for the INTERPRETER PHP

while this
> echo o()->q;
can be interpreted because of the design of the interpreter.

I can live with that.

[email protected]

"Tom Worster" <[email protected]> wrote in message
news:c6d13522.12422%[email protected]...
> On 9/12/09 9:50 AM, "Tom Worster" <[email protected]> wrote:
>
> > On 9/12/09 1:32 AM, "Lars Torben Wilson" <[email protected]> wrote:
> >
> >> Tom Worster wrote:
> >>> if i have an expression that evaluates to an object, the return value
from a
> >>> function, say, and i only want the value of one of the objects
properties,
> >>> is there a tidy way to get it without setting another variable?
> >>>
> >>> to illustrate, here's something that doesn't work, but it would be
> >>> convenient if it did:
> >>>
> >>> $o = array( (object) array('a'=>1), (object) array('a'=>2) );
> >>>
> >>> if ( end($o)->a > 1 ) {  // can't use -> like this!
> >>> ...
> >>> }
> >>
> >> What version of PHP are you using? Your example should work.
> >>
> >> Torben
> >
> > 5.2.9.
> >
> > what version does it work in?
>
> i shamefully beg your pardon, lars. i was sure i tested the example but
it's
> clear to me now i either didn't or i made a mistake. end($o)->a IS php
> syntax! so -> may follow a function (or method, i guess) call.
>
> but let me give you a more different example:
>
> $a and $b are normally both objects, each with various members including a
> prop q, but sometimes $a is false. i want the q of $a if $a isn't false,
> otherwise that of $b.
>
> ($a ? $a : $b)->q   // is not php, afaik
>
> before you suggest one, i know there are simple workarounds.
>
> but mine is a theoretical question about syntax, not a practical one. i'm
> exploring php's syntactic constraints on the -> operator in contrast to,
> say, the + or . operators. and in contrast to other languages.
>
> for example, the . in js seems more generally allowed than -> (or, for
that
> matter, []) in php. programmers (especially using jquery) are familiar
with
> using . after an expression that evaluates to an object, e.g.
>
> <body>
> <p id="thepara" class="top x23 indent">My x class number is
>     <span id="num"></span></p>
> <div id="mandatory" style="border: solid red 1px"></div>
> <script type="text/javascript">
> document.getElementById('num').innerText =
>   ( ( document.getElementById('optional')
>       || document.getElementById('mandatory')
>     ).appendChild(document.getElementById('thepara'))
>     .className.match(/x(\d+)/) || [0,'absent']
>   )[1]
> </script>
> </body>
>
> which shows . after objects, method calls and expressions (as well as the
[]
> operator applied to an expression).
>
> do we just live without in phpville or am i missing something?
>
>
> and while i'm at it, and using my original error, how come...
>
> function o() { return (object) array('q'=>7); }
> echo o()->q;  // is ok syntax, but
>
> function a() { return array('q'=>5); }
> echo a()['q'];  // isn't?
>
>
>



--- End Message ---
--- Begin Message ---
At 9:19 PM -0700 9/11/09, aveev wrote:
The reason why I used incremental value from the db is that I need a sequence
number generator that can be used as an argument to my function. If I can
generate sequence number myself, I don't need this incremental value from
db.
What I want is that the sequential alphanumeric id that increments it's
numeric value by one everytime a new record is inserted while the alphabet
part remains the same..(like I've shown before):
AAA0001
AAA0002
...
AAA0009
AAA0010
This id will be used as the application number that will be printed as a
barcode on the user's application form. The requirement says that the app
number is prefixed with the letters (actually it's not 'AAA' but 'FIN' which
stands for File Identification Number)....


Things to consider.

First, if all your application-numbers start with FIN, then my advice would be to do this after you pull the ID from the database. Why store an additional three characters for each ID? And why make your code more complicated than it should be?

Second, considering that you want sequential numbering, are you prepared for what what happens when you delete an item? You either live with gaps in your sequence (recommended) or you renumber.

Third, your example limits the number of applications to 9999 (i.e., AAA9999 (seven characters)), is that correct OR is the next number AAA1000 (eight characters)? If the next number is eight characters, then why not use "AAA1" as the start of the sequence? Why the extra zeros?

Fourth, if you are going to use the index of the table for creating the application-number and require the addition of the alpha prefix, then I would create another field in the table and store the application-numbers there.

For example, I would use (not tested):

// code to create a record (i.e., INSERT INTO your_table (whatever) VALUES ('$whatever') )

$id = LAST_INSERT_ID();

The above statement finds the last record added to the database (the index of the record) and then I would create my application-number and store it in that record -- like so:

// code to create the application-number (i.e., $application-number = 'AAA' . $id; )

$query = "UPDATE your_table SET application_number = '$application_number' WHERE id = '$id' ";
$result  = mysql_query($query) or die('Error, query failed');

That way you should not have any duplications and you have application-numbers (as you want )that are tied to the auto-numbering of the table's index.

HTH's

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

--- End Message ---
--- Begin Message ---
At 6:02 PM -0400 9/11/09, Paul M Foster wrote:

I typically use us2.php.net, which is hosted by Hurricane Electric.

Paul

Paul:

I wouldn't use Hurricane Electric if their accounts were provided for free!

The following is an experience I had with Hurricane Electric and support for my opinion as to their "service".

You see, many years ago Hurricane Electric hosted (IMO with complicity) a porn site that sent out over 2000 porn spams to AOL using MY email address as the person to contact. That incident caused me a great deal of trouble.

In an attempt to understand and resolve the problem, I sent several emails to Hurricane Electric; I called them numerous times via telephone; and I even sent them letters via the US mail. But unfortunately they refused to answer ANY of my correspondence. Their lack of communication provided support for my opinion of their complicity with what had happened.

A few years back they contacted me (again more spam) soliciting my interest in hosting with them. Normally, I would have just reported such spam to spamcop, but because of the incident I replied and told them what had happened.

Later I was contacted by one of their technicians who looked thorough their records and confirmed/admitted the incident. However, he told me that they could not be held responsible for they clients they host. Furthermore, they have no intention of screening their clients. He said that they will provide hosting to whomever they want, including porn and spam sites. If their clients do anything wrong per "their standards", then they will deal with it internally. Otherwise they don't care about any harm done to anyone by them hosting such sites. In short, they want the money but not the responsibility.

Now, maybe Hurricane Electric has changed its ways, but they can't change their past.

In my opinion, there are more than enough hosting companies who care about the damage they might cause and take steps to reduce the about spam and porn on the net. My advice, seek hosts other than Hurricane Electric.

Cheers,

tedd

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

--- End Message ---

Reply via email to