php-windows Digest 31 Aug 2004 16:10:19 -0000 Issue 2377
Topics (messages 24467 through 24480):
PHP Related Questions
24467 by: operationsengineer1.yahoo.com
GD problem
24468 by: Joakim Ling, Lokalguiden
24470 by: Joakim Ling, Lokalguiden
Strange 'if' test bug?
24469 by: Steve McGill
24477 by: Gryffyn, Trevor
24478 by: Christian Zambrano
24480 by: Charles P. Killmer
Re:[PHP-WIN] Strange 'if' test bug?
24471 by: william.candillon.tiscali.fr
24472 by: Steve McGill
24473 by: Nadim Attari
24475 by: Steve McGill
24479 by: Frank M. Kromann
Forgot Password
24474 by: Jagannath Joshi
Authors and Instructors Needed
24476 by: Keystone Learning Systems
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 ---
Hi, I am relatively new to PHP and brand new to PHP interacting with databases. I
will do my development on my WinXP Home laptop and host my actual site at a Linux
based hosting service.
I have two questions.
First, Has anybody had any success installing apache 1.3.31 as a module for WinXP Home
Edition? I've followed the instructions outlined here
http://us4.php.net/manual/en/install.windows.manual.php
and
http://us4.php.net/manual/en/install.windows.apache1.php
to a "T." The result is that my web browser gives me a "download or open" dialogue
box b/c it doesn't recognize PHP extensions. I have since configured PHP as CGI, but
I understand that one can't have a persistent database connection with a CGI set up.
Any help would be appreciated.
Secondly, I am trying to DBG debugger to work with PHP Coder. I followed the DBG
instructions, however, I get a whole bunch of nothing when I run "debugger" from PHP
Coder.
Any help here would be greatly appreciated.
---------------------------------
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
--- End Message ---
--- Begin Message ---
Hi,
Is it possible to resize jpg/gif from gd 1.7, its working fine in gd 2.0
and my webbserver wont upgrade.
This is my example (not working in gd 1.7)
<?php
// 1.php
header("Content-type: image/jpeg");
$img = $_GET["img"];
$imgSource = @getimagesize($img);
$imgWidth = $imgSource[0];
$imgHeight = $imgSource[1];
$imgType = $imgSource[2];
switch($imgType) {
case 1: $imgSource = imagecreatefromgif($img); break;
case 2: $imgSource = imagecreatefromjpeg($img); break;
case 3: $imgSource = imagecreatefrompng($img); break;
case 15: $imgSource = imagecreatefromwbmp($img); break;
default: exit;
}
$h = ($_GET["w"]/$imgWidth)*$imgHeight;
$imgTN = @imagecreatetruecolor($_GET["w"], $h);
imagecopyresized($imgTN, $imgSource, 0, 0, 0, 0, $_GET["w"], $h,
$imgWidth, $imgHeight);
imagejpeg($imgTN, null, 80);
imagedestroy($imgTN);
?>
<img src="1.php?img=1.jpg&w=70&q=70">
--- End Message ---
--- Begin Message ---
Hi,
Is it possible to resize jpg/gif from gd 1.7, its working fine in gd 2.0 and
my webbserver wont upgrade.
This is my example (not working in gd 1.7)
<?php
// 1.php
header("Content-type: image/jpeg");
$img = $_GET["img"];
$imgSource = @getimagesize($img);
$imgWidth = $imgSource[0];
$imgHeight = $imgSource[1];
$imgType = $imgSource[2];
switch($imgType) {
case 1: $imgSource = imagecreatefromgif($img); break;
case 2: $imgSource = imagecreatefromjpeg($img); break;
case 3: $imgSource = imagecreatefrompng($img); break;
case 15: $imgSource = imagecreatefromwbmp($img); break;
default: exit;
}
$h = ($_GET["w"]/$imgWidth)*$imgHeight;
$imgTN = @imagecreatetruecolor($_GET["w"], $h);
imagecopyresized($imgTN, $imgSource, 0, 0, 0, 0, $_GET["w"], $h, $imgWidth,
$imgHeight);
imagejpeg($imgTN, null, 80);
imagedestroy($imgTN);
?>
<img src="1.php?img=1.jpg&w=70&q=70">
--- End Message ---
--- Begin Message ---
Sorry if this is a newbie FAQ,
<?php
$key=0;
if($key == "muppet") {
echo "key is a muppet: $key";
} else {
echo "key is something else: $key";
}
?>
Will print completely the wrong line:
====> key is a muppet: 0
If I use three equals signs, i.e. ===, then the test works.
But if I use linux, the test works as expected with two equals signs.
What on earth am I missing?
Using Windows PHP 4.3.8 as a CGI, on Apache 1.3.31.
Many thanks in advance for any help,
Steve
--- End Message ---
--- Begin Message ---
The only thing I can think of, and it still doesn't totally add up, but
when you do "$key = 0;", you're assigning an integer to $key. You then
do a comparison of 0 (integer) == "muppet" (string).
0 is also symbolic of "false" as well, correct?
If I replace 0 with FALSE, I get "key is something else: " (nothing
after the ":") but when I replace 0 with TRUE, I get "key is a muppet:
1".
Anyway, I was wondering if it had something to do with variable typing.
I've heard PHP referred to as "typeless" but variables do have a type
and if you're not explicit about what you want it to be, it'll auto-type
the variable based on what data you assign to it.
$key = 0; # $key is type int
$key = "zero"; # $key is now type string
If you do:
$key = (string) 0;
It's the same as doing:
$key = "0";
Btw, Here's the passage from the PHP help file about typing:
"PHP does not require (or support) explicit type definition in variable
declaration; a variable's type is determined by the context in which
that variable is used. That is to say, if you assign a string value to
variable $var, $var becomes a string. If you then assign an integer
value to $var, it becomes an integer."
The reason my brain went down this path is because "===" means something
is "identical". Same value AND type:
"$a == $b Equal TRUE if $a is equal to $b.
$a === $b Identical TRUE if $a is equal to $b, and they are of the same
type. (PHP 4 only)"
(again from the PHP help)
So it sounds like it's type related, but it still doesn't make any
sense. "muppet" should evaluate to TRUE according to that PHP cheat
sheet that was posted. And 0 should evaluate to FALSE.
Interesting issue. Thanks for posting about it Steve!
Maybe it's some configuration difference between your linux system and
your windows box. Either system or some PHP.INI type thing. Let us know
if you figure it out.
-TG
> -----Original Message-----
> From: Steve McGill [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, August 31, 2004 4:35 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-WIN] Strange 'if' test bug?
>
>
> Sorry if this is a newbie FAQ,
>
> <?php
> $key=0;
> if($key == "muppet") {
> echo "key is a muppet: $key";
> } else {
> echo "key is something else: $key";
> }
> ?>
>
> Will print completely the wrong line:
>
> ====> key is a muppet: 0
>
> If I use three equals signs, i.e. ===, then the test works.
>
> But if I use linux, the test works as expected with two equals signs.
>
> What on earth am I missing?
>
> Using Windows PHP 4.3.8 as a CGI, on Apache 1.3.31.
>
> Many thanks in advance for any help,
> Steve
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
$key=0;
$key=="muppet"?TRUE:FALSE;
The reason this last comparison returns true is that since you are comparing
an integer with a string, the strings gets converted to an integer and since
"muppet" does not have any numeric character it gets converted to 0. In
other words as far PHP in concerned you are comparing 0 with 0 which is why
the result of comparison is a true statement.
Any thoughts on this?
Thanks
Christian
--- End Message ---
--- Begin Message ---
I would think that PHP should make the conversion in the other direction
to avoid losing data. In other words, if a conversion is necessary,
convert to the data type that can handle the greater variety of data.
In this case to strings. It would probably always be to strings though.
Charles
-----Original Message-----
From: Christian Zambrano [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 31, 2004 10:35 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-WIN] Strange 'if' test bug?
$key=0;
$key=="muppet"?TRUE:FALSE;
The reason this last comparison returns true is that since you are
comparing an integer with a string, the strings gets converted to an
integer and since "muppet" does not have any numeric character it gets
converted to 0. In other words as far PHP in concerned you are comparing
0 with 0 which is why the result of comparison is a true statement.
Any thoughts on this?
Thanks
Christian
--
PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
According to me it's a very strange problem
Test this please :
$key = '0';
if($key == 'muppet')
echo 'key is a muppet: ".$key;
else
echo 'key is something else: '.$key;
Because I don't understang why $key return false :(
---------- Initial Header -----------
From : "Steve McGill" <[EMAIL PROTECTED]>
To : [EMAIL PROTECTED]
Cc :
Date : Tue, 31 Aug 2004 10:35:01 +0200
Subject : [PHP-WIN] Strange 'if' test bug?
Sorry if this is a newbie FAQ,
<?php
$key=0;
if($key == "muppet") {
echo "key is a muppet: $key";
} else {
echo "key is something else: $key";
}
?>
Will print completely the wrong line:
====> key is a muppet: 0
If I use three equals signs, i.e. ===, then the test works.
But if I use linux, the test works as expected with two equals signs.
What on earth am I missing?
Using Windows PHP 4.3.8 as a CGI, on Apache 1.3.31.
Many thanks in advance for any help,
Steve
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
************************ ADSL ILLIMITE TISCALI + TELEPHONE GRATUIT
************************
Surfez 40 fois plus vite pour 30EUR/mois seulement ! Et t�l�phonez partout en France
gratuitement,
vers les postes fixes (hors num�ros sp�ciaux). Tarifs tr�s avantageux vers les mobiles
et l'international !
Pour profiter de cette offre exceptionnelle, cliquez ici :
http://register.tiscali.fr/adsl (voir conditions sur le site)
--- End Message ---
--- Begin Message ---
Yes, I forgot to mention this:
if $key=0, then $key == 'muppet' equates to TRUE
if $key="0", then $key == 'muppet' equates to FALSE
Bit crazy...?
Steve
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> schreef in
bericht news:[EMAIL PROTECTED]
According to me it's a very strange problem
Test this please :
$key = '0';
if($key == 'muppet')
echo 'key is a muppet: ".$key;
else
echo 'key is something else: '.$key;
Because I don't understang why $key return false :(
---------- Initial Header -----------
>From : "Steve McGill" <[EMAIL PROTECTED]>
To : [EMAIL PROTECTED]
Cc :
Date : Tue, 31 Aug 2004 10:35:01 +0200
Subject : [PHP-WIN] Strange 'if' test bug?
Sorry if this is a newbie FAQ,
<?php
$key=0;
if($key == "muppet") {
echo "key is a muppet: $key";
} else {
echo "key is something else: $key";
}
?>
Will print completely the wrong line:
====> key is a muppet: 0
If I use three equals signs, i.e. ===, then the test works.
But if I use linux, the test works as expected with two equals signs.
What on earth am I missing?
Using Windows PHP 4.3.8 as a CGI, on Apache 1.3.31.
Many thanks in advance for any help,
Steve
--- End Message ---
--- Begin Message ---
http://www.blueshoes.org/en/developer/php_cheat_sheet/
------------------
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> a �crit dans
le message de news:[EMAIL PROTECTED]
According to me it's a very strange problem
Test this please :
$key = '0';
if($key == 'muppet')
echo 'key is a muppet: ".$key;
else
echo 'key is something else: '.$key;
Because I don't understang why $key return false :(
--- End Message ---
--- Begin Message ---
Well gee, thanks a lot for that....
I can't imagine why 0 == "foo" should be TRUE, but there it is.... I will
use === from now on.
I was convinced this was related to windows because I've never noticed this
behaviour with several years of experience with programming PHP on linux
systems.
Thanks for your patience, and your answer.
Best wishes,
Steve
"Nadim Attari" <[EMAIL PROTECTED]> schreef in bericht
news:[EMAIL PROTECTED]
> http://www.blueshoes.org/en/developer/php_cheat_sheet/
> ------------------
>
> "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> a �crit dans
> le message de news:[EMAIL PROTECTED]
> According to me it's a very strange problem
> Test this please :
> $key = '0';
> if($key == 'muppet')
> echo 'key is a muppet: ".$key;
> else
> echo 'key is something else: '.$key;
> Because I don't understang why $key return false :(
--- End Message ---
--- Begin Message ---
Hi Steve,
0 and "foo" are two different types (int and string). In order to compare
these values they must be converted into the same type. PHP does that by
converting "foo" to an integer and that value will be 0, hence the true
value on compare with ==. when you use === to compare the two values need
to be of the same type to evaluate to true.
you can trick the compare by doing stuff like this:
if ("$key" == "muppet") (
}
- Frank
> Well gee, thanks a lot for that....
>
> I can't imagine why 0 == "foo" should be TRUE, but there it is.... I
will
> use === from now on.
>
> I was convinced this was related to windows because I've never noticed
this
> behaviour with several years of experience with programming PHP on
linux
> systems.
>
> Thanks for your patience, and your answer.
>
> Best wishes,
> Steve
>
> "Nadim Attari" <[EMAIL PROTECTED]> schreef in bericht
> news:[EMAIL PROTECTED]
> > http://www.blueshoes.org/en/developer/php_cheat_sheet/
> > ------------------
> >
> > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> a �crit
dans
> > le message de
news:[EMAIL PROTECTED]
> > According to me it's a very strange problem
> > Test this please :
> > $key = '0';
> > if($key == 'muppet')
> > echo 'key is a muppet: ".$key;
> > else
> > echo 'key is something else: '.$key;
> > Because I don't understang why $key return false :(
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
Hi All,
Am new to PHP/MySQL technology, here am using Dreamweaver to develop Web
Application
I would like to know, is there any extension for Retrieve Password?
If not, then where can i found code for Forgot Password option..
I appreciate your time & inputs
Thanks
Jaggu
--- End Message ---
--- Begin Message ---
KeyStone Learning Systems (www.keystonelearning.com) is currently seeking subject
matter experts to work with us to author future courseware titles delivered via
CD-ROM, VHS, DVD and the Web.
Are you a leading expert or trainer in your field? Do you have a passion or desire to
teach others?
Have you always wanted to be a published author but haven't had the time or
opportunity to pursue your goal?
KeyStone has been working with leading experts for more than 15 years in the areas of
desktop software, development, programming and certification topics to develop
computer and video-based courseware.
Our products are used by more than 500,000 active professional users and sold along
with more than 1,200 course titles in some of the following categories:
- Professional Certifications, such as MCSE and CCNA
- Application and Web Developers, such as Java, SQL and VB.Net
- Desktop Applications, such as Microsoft Office, QuickBooks and Publisher
- Digital Media Applications, such as Macromedia Flash and Adobe Photoshop
- Professional Soft skills, such as Project Management and Accounting
- Other Information Technology, Communications and development related courses
If you are interested in joining our team of leading experts, we encourage you to
visit our site at http://www.keystonelearning.com/keystone/sme for additional
information.
Thank you.
The KeyStone Team
--- End Message ---