php-general Digest 4 Oct 2009 14:31:15 -0000 Issue 6373
Topics (messages 298544 through 298555):
[SOLVED] Re: Missing php5apache2.dll
298544 by: Floydian
Re: windows 5.2.10 PHP not working with phpinfo
298545 by: Fred Silsbee
Re: A really wacky design decision
298546 by: clancy_1.cybec.com.au
298547 by: clancy_1.cybec.com.au
298548 by: Andrea Giammarchi
298549 by: Andrea Giammarchi
298552 by: Tom Worster
Re: Self-Process php forms or not?
298550 by: MEM
298553 by: Tom Worster
class to generate Javascript Object ??
298551 by: Michael A. Peters
298554 by: Tom Worster
298555 by: Andrea Giammarchi
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 ---
Floydian wrote:
Hello, I've downloaded the VC6 PHP 5.3.0 windows zip
(php-5.3.0-nts-Win32-VC6-x86.zip) and I don't see the file
php5apache2.dll in it. php5apache.dll is in there, but the apache 2 file
isn't. Where can I find this file?
I've found the dll :)
The php5apache2.dll and php5apache2_2.dll files are in the thread safe
version. php-5.3.0-Win32-VC6-x86.zip
Cheers
--- End Message ---
--- Begin Message ---
--- On Mon, 8/31/09, hack988 hack988 <[email protected]> wrote:
> From: hack988 hack988 <[email protected]>
> Subject: Re: [PHP] windows 5.2.10 PHP not working with phpinfo
> To: "Fred Silsbee" <[email protected]>
> Cc: [email protected]
> Date: Monday, August 31, 2009, 6:35 AM
> Please set
> log_error=on,error_reporting=E_ALL,error_log=syslog in
> php.ini and then,see error detail in syslog.
>
> 2009/8/31 Fred Silsbee <[email protected]>:
> > I got 5.3 working but found out there was no
> php_mssql.dll for it.
> > Somebody (who didn;t know) said I had to return to
> 5.2.8 but I found no 5.2.8 so I am trying 5.2.10
> > _________________________________________problem:
> > under IE8:
> > http://72.47.28.128:8080/phpinfo.php
> > with:
> > <?php
> > phpinfo();
> > ?>
> >
> > I get :
> > The website cannot display the page
> > HTTP 500
> > Most likely causes:
> > •The website is under maintenance.
> > •The website has a programming error.
> > ___________________________________________
> >
> > I installed :
> > php-5.2.10-Win32-VC6-x86.zip and put php.ini in C:\PHP
> and C:\PHP\ext
> > AND C:\WINDOWS, C:\WINDOWS\system and
> C:\WINDOWS\system32
> >
> > I installed FastCGI 1.5 !
> >
> > In php.ini I put :
> > ________________________________
> >
> > cgi.force_redirect = 0 //
> for CGI
> >
> > extension_dir = "C:\PHP\ext"
> >
> > commented out
> > ;doc_root = "C:\inetpub\wwwroot" // for IIS/PWS
> > leaving
> > doc_root =
> > _________________________________________________
> > IIS 5.1 properties->configuration I added .php
> C:\PHP\php5ts.dll
> > GET,HEAD,POST,DEBUG
> >
> > Maybe php-win.exe
> > _________________________________________________
> >
> > I added to the XP Prof environment path
> ;C:\PHP\;C:\PHP\ext\
> >
> > I created an environment variable (and rebooted) PHPRC
> = C:\PHP;C:\PHP\ext
> >
> >
> > I never found any statement of the necessity of
> requiring CGI
> >
> > The instructions ramble around
> >
> >
> >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
thanks! Weeks back I got it to work by retreating to 5.2.6
and altering permissions in admin. This alteration may open the way for
5.3 to work!
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--- End Message ---
--- Begin Message ---
I am well aware of the === operator, but I had an uneasy feeling that there was
still a
trap. However when I tried it it worked, so I was going to thank you for your
suggestion,
though I find the concept of having separate 'sort of equal' and 'truly equal'
operators
decidedly distasteful, but then I discovered that if you have:
$a = 2260; $b = 226e1; $c = 2.26e3; $d = 2260.0;
$a==$b==$c==$d,
and
$b===$c===$d
Granted $c & $d are less likely to be encountered by accident, but if I want to
be certain
the two strings match I will have to stick to the (string) cast or use strcmp.
Perhaps we
need a 'really & truly equal' operator ====!
Clancy
>
>And then you discover ===
>
>$i = 0; $j = count ($names); while ($i < $j)
>{ if ($names[$i] === $target) { break; }
>++$i;
> }
>
>... regards
>
>> To: [email protected]
>> From: [email protected]
>> Date: Sat, 3 Oct 2009 21:21:00 +1000
>> Subject: [PHP] A really wacky design decision
>>
>> Daevid Vincent is surprised that:
>>
>> $num = 123;
>> $num = $num++;
>> print $num; //this prints 123 and not 124 ?!!
>>
>> To me this is relatively logical. As I understand it, the post-increment
>> operator says "do
>> something with the variable, and then increment it. The trouble in this case
>> is that we
>> are doing something irrational; we are copying the number back to itself,
>> and to me it is
>> reasonably logical (or at least no less illogical than the alternative) to
>> assume that if
>> we copy it to itself, then increment the original version, the copy will not
>> be
>> incremented.
>>
>> However there is one feature of PHP which, to my mind, is really bad design.
>> How many of
>> you can see anything wrong with the following procedure to search a list of
>> names for a
>> particular name?
>>
>> $i = 0; $j = count ($names); while ($i < $j)
>> { if ($names[$i] == $target) { break; }
>> ++$i;
>> }
>>
>> As long as the names are conventional names, this procedure is probably safe
>> to use.
>> However if you allow the names to be general alphanumeric strings, it is not
>> reliable. One
>> of my programs recently broke down in one particular case, and when I
>> eventually isolated
>> the bug I discovered that it was matching '2260' to '226E1'. (The logic of
>> this is: 226E1
>> = 226*10^1 = 2260).
>>
>> I agree that I was well aware of this trap, and that I should not have used
>> a simple
>> comparison, but it seems to me to be a bizarre design decision to assume
>> that anything
>> which can be converted to an integer, using any of the available notations,
>> is in fact an
>> integer, rather than making the default to simply treat it as a string. It
>> is also a trap
>> that it is very easy to fall into if you start off thinking about simple
>> names, and then
>> extend (or borrow) the procedure to use more general strings.
>>
>> And can anyone tell me whether, in the above case, it is sufficient to write
>> simply:
>> if ((string) $names[$i] == $target),
>>
>> or should I write:
>> if ((string) $names[$i] == (string) $target)?
>>
>> (I decided to play safe and use strcmp ().)
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>_________________________________________________________________
>Windows Live: Keep your friends up to date with what you do online.
>http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_1:092010
--- End Message ---
--- Begin Message ---
On Sat, 03 Oct 2009 11:57:36 -0400, [email protected] (Tom Worster) wrote:
>On 10/3/09 7:21 AM, "[email protected]" <[email protected]> wrote:
>
>> However there is one feature of PHP which, to my mind, is really bad design.
>> How many of
>> you can see anything wrong with the following procedure to search a list of
>> names for a
>> particular name?
>>
>> $i = 0; $j = count ($names); while ($i < $j)
>> { if ($names[$i] == $target) { break; }
>> ++$i;
>> }
>>
>> As long as the names are conventional names, this procedure is probably safe
>> to use.
>> However if you allow the names to be general alphanumeric strings, it is not
>> reliable. One
>> of my programs recently broke down in one particular case, and when I
>> eventually isolated
>> the bug I discovered that it was matching '2260' to '226E1'. (The logic of
>> this is: 226E1
>> = 226*10^1 = 2260).
>>
>> I agree that I was well aware of this trap, and that I should not have used a
>> simple
>> comparison, but it seems to me to be a bizarre design decision to assume that
>> anything
>> which can be converted to an integer, using any of the available notations,
>> is
>> in fact an
>> integer, rather than making the default to simply treat it as a string.
>
>this is odd.
>
>i might think it ok for (2260 == '226E1') to be true since php would be
>doing type juggling in a logical left-to-right manner: we start with an
>integer 2260, next is the juggling comparison operator, then a string, so it
>might reasonably try to convert the string to an integer and then compare.
>
>but with ('2260' == '226E1'), where both lhs and rhs are already of the same
>time, it seems elliptical, to say the least, that php should search the
>types to which it can convert the strings looking for one in which they are
>equal.
The order doesn't matter; 2260 == 226e1, and 226e1==2260.
It looks as if (for comparisons) PHP's order of preference is Integer > Real >
?? > ?? >
String.
If you use '==' it will try to convert everything to integer, but if you use
'===' it will
try to render them in some standard format (so that 226e1 === 2.26e3), but will
not
convert real to integer. Despite which if you print them without specifying a
format it
will print them all as 2260.
All very messy!
Clancy
--- End Message ---
--- Begin Message ---
> $a = 2260; $b = 226e1; $c = 2.26e3; $d = 2260.0;
>
> $a==$b==$c==$d,
>
> and
> $b===$c===$d
$b , $c, and $d are the same indeed ... they represent the floating point
2260.0 in I think every language ... it's like saying that 1.0 is not 1.0000
... both floating point numbers, so I don't get your problem ...
_________________________________________________________________
Windows Live: Make it easier for your friends to see what you’re up to on
Facebook.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_2:092009
--- End Message ---
--- Begin Message ---
> All very messy!
there is nothing messy, the logic is well defined and for a loose type language
it's absolutely normal behavior.
Regards
_________________________________________________________________
Keep your friends updated—even when you’re not signed in.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_5:092010
--- End Message ---
--- Begin Message ---
On 10/4/09 6:36 AM, "[email protected]" <[email protected]> wrote:
>> i might think it ok for (2260 == '226E1') to be true since php would be
>> doing type juggling in a logical left-to-right manner: we start with an
>> integer 2260, next is the juggling comparison operator, then a string, so it
>> might reasonably try to convert the string to an integer and then compare.
>>
>> but with ('2260' == '226E1'), where both lhs and rhs are already of the same
>> time, it seems elliptical, to say the least, that php should search the
>> types to which it can convert the strings looking for one in which they are
>> equal.
>
> The order doesn't matter; 2260 == 226e1, and 226e1==2260.
in those two cases, all four operands are integer literals. no juggling is
involved.
and i would have expected the same for ('2260' == '226e1') and ('226e1' ==
'2260') since all operands are string literals and i'd be wrong. (evidently
i'm not alone in making this mistake.)
i get confused reading the manual:
http://www.php.net/manual/en/language.types.type-juggling.php
says that the context determines if the expression is converted. the example
being the + operator. by definition, it's operands are numeric contexts so
strings are converted. fair enough.
now what about the == operator?
http://www.php.net/manual/en/language.operators.comparison.php
that page contradicts the previous one because it says that, when an operand
is a string, the determination to convert an operand depends not on the
context but on the specific data _of_ the operand.
i think robert captured the essence of this confusion nicely with:
>
> On 10/3/09 1:53 PM, "Robert Cummings" <[email protected]> wrote:
>
>> Numeric strings are special :)
>>
--- End Message ---
--- Begin Message ---
Thanks a lot. To all.
For the moment, I'm with the redirect solution that others have pointed.
But after seen tedd example and watch Manuel videos, I'm starting to
understand how the hidden field solution work as well. Well... I'm
*starting* to understand I've not fully understand it yet, despite all your
great examples.
Because the structure of the code with hidden fields, seems quite different
from the structure I have right now and I'm unable to make the switch.
Here is the actual structure:
if (isset($_POST['submit']))
{
//declare variables
$var = $_POST['var']; etc...
//validate
//process the form
(send e-mail or save to database etc...)
//redirect to success page.
}
else
{
Echo "Sorry, couldn't process the form";
}
<html form>
I suppose that the echo message telling "we couldn't process the form" does
not appear when the form first loads, because the server side script is not
requested on load, it is requested when the form submits to the php code
presented on that same page (self). Tom Worster, is this precise?
In the future, I will print tedd example, and Manuel scheme, and try to
change the code above to accommodate hidden fields, because I still prefer
having only one file.
Thank you all once again,
Márcio
--- End Message ---
--- Begin Message ---
On 10/4/09 9:25 AM, "MEM" <[email protected]> wrote:
> Thanks a lot. To all.
> For the moment, I'm with the redirect solution that others have pointed.
>
> But after seen tedd example and watch Manuel videos, I'm starting to
> understand how the hidden field solution work as well. Well... I'm
> *starting* to understand I've not fully understand it yet, despite all your
> great examples.
>
> Because the structure of the code with hidden fields, seems quite different
> from the structure I have right now and I'm unable to make the switch.
>
> Here is the actual structure:
>
> if (isset($_POST['submit']))
> {
>
> //declare variables
> $var = $_POST['var']; etc...
>
> //validate
>
> //process the form
> (send e-mail or save to database etc...)
>
> //redirect to success page.
> }
> else
> {
> Echo "Sorry, couldn't process the form";
> }
>
> <html form>
>
> I suppose that the echo message telling "we couldn't process the form" does
> not appear when the form first loads, because the server side script is not
> requested on load, it is requested when the form submits to the php code
> presented on that same page (self). Tom Worster, is this precise?
i don't think so. if the user requests the page "a_form.php" then the server
will normally execute the a_form.php script regardless whether the form was
submitted or not.
to display a blank form, the user probably requests a_form.php with the GET
method and probably without any GET parameters. the script will run but
$_POST['submit'] is not set. so the script you show above will echo "Sorry,
couldn't process the form". that will likely confuse the user.
in your structure you branch only two ways. i think you need three ways:
1 - the user simply arrived at the form. there is no POST data. the form was
not submitted.
2 - there is POST data. the form was submitted.
2a - the POST data is unacceptable.
2b - the POST data is good.
in branches 1 and 2a you send the form.
in 2b, you send some other page or a redirect.
in 1 you send the form blank.
in 2a you might fill some form elements with data from POST and add some
annotations to the form so the user knows what she or he did wrong.
> In the future, I will print tedd example, and Manuel scheme, and try to
> change the code above to accommodate hidden fields, because I still prefer
> having only one file.
one can learn a lot reading other people's code.
--- End Message ---
--- Begin Message ---
I wrote a php class to generate flowplayer/html5 media code for my site:
http://www.shastaherps.org/xml_MMmediaClass.phps
The "buildFlashvars()" function in it is really ugly and will be a pain
to update as I modify the class in the future.
What it does is generate a JavaScript object string, as described here:
http://flowplayer.org/tools/flashembed.html
I'm thinking (hoping) there is already a php class somewhere for
generating JavaScript object strings that I can instead of my ugly
easily breakable way of doing it.
Anyone know of one?
--- End Message ---
--- Begin Message ---
On 10/4/09 9:39 AM, "Michael A. Peters" <[email protected]> wrote:
> I wrote a php class to generate flowplayer/html5 media code for my site:
>
> http://www.shastaherps.org/xml_MMmediaClass.phps
>
> The "buildFlashvars()" function in it is really ugly and will be a pain
> to update as I modify the class in the future.
>
> What it does is generate a JavaScript object string, as described here:
>
> http://flowplayer.org/tools/flashembed.html
>
> I'm thinking (hoping) there is already a php class somewhere for
> generating JavaScript object strings that I can instead of my ugly
> easily breakable way of doing it.
>
> Anyone know of one?
would json_encode() work for you... ?
http://www.php.net/manual/en/function.json-encode.php
--- End Message ---
--- Begin Message ---
> I'm thinking (hoping) there is already a php class somewhere for
> generating JavaScript object strings that I can instead of my ugly
> easily breakable way of doing it.
>
> Anyone know of one?
json_encode
http://uk3.php.net/manual/en/function.json-encode.php
Regards
_________________________________________________________________
Windows Live Hotmail: Your friends can get your Facebook updates, right from
Hotmail®.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009
--- End Message ---