php-windows Digest 11 Nov 2004 18:48:28 -0000 Issue 2465

Topics (messages 24963 through 24968):

Re:
        24963 by: marcot.tabini.ca

Re: Apache2+PHP5+MySQL4 --> mysql_connect fails, PHP5+MySQL4+CLI --> 
mysql_connect works
        24964 by: Herson

Question concerning SWITCH and Comparisons
        24965 by: Tony Devlin
        24966 by: Gryffyn, Trevor
        24967 by: Svensson, B.A.T. (HKG)

Apache
        24968 by: W Roothman

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 ---
From: [EMAIL PROTECTED]
Subject: I'm currently away

Hello,

Our offices will be closed between November 4th and November 12th included. 
During that time, I will have no access to e-mail or voicemail.

If your message is related to php|architect support, please write to [EMAIL 
PROTECTED] instead, and someone will be happy to assist you.

For all other messages of an urgent nature, you can instead write to Arbi 
Arzoumani ([EMAIL PROTECTED]).

Please note that I receive a large amount of e-mail. Therefore, it might take 
me a while to return your message once I am back at the office.

Cheers,


Marco Tabini
-------- Original Message --------

--- End Message ---
--- Begin Message ---
G'day!
I've same problem! and I do this, I'm set the phpinidir but nothing 
happened. The problem continues...
I think that the problem are in the PHP 5.0.2, because I've never saw this 
in other versions!

"Steven James Samuel Stapleton" <[EMAIL PROTECTED]> escreveu na 
mensagem news:[EMAIL PROTECTED]
> Fixed: For some reason Apache wanted a php.ini in the windows directory 
> rather than in the PHP install directory. Explicitly set the PhpIniDir in 
> the httpd.conf and fixed it.
>
> -Jim
>
> ----- Original Message ----- 
> From: "Steven James Samuel Stapleton" <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Wednesday, November 10, 2004 7:00 PM
> Subject: [PHP-WIN] Apache2+PHP5+MySQL4 --> mysql_connect fails, 
> PHP5+MySQL4+CLI --> mysql_connect works
>
>
>> Relevant information:
>> Windows XP Pro SP2
>> PHP 5.0.2
>> MySQL 4.0.21-nt
>> Apache 2
>>
>> PATH:
>> C:\WINDOWS\system32
>> C:\c\WINDOWS
>> C:\WINDOWS\System32\Wbem
>> C:\WBP\php               //PHP bin dir
>> C:\WBP\Apache2\bin  //Apache bin dir
>>
>> MySQL's bin dir is not in path
>>
>> I have tried calling
>> mysql_connect(...) with PHP's php_mysql.dll in and not-in the path.
>>
>>
>> CLI works great, database gets put through hoops, lots of changes, all is 
>> good.
>>
>> In Apache, it fails at the connect:
>> Fatal error: Call to undefined function mysql_connect() in 
>> C:\WBP\WBP\lib\db_capsule_mysql.php on line 124
>>
>> both classes are using the same conect routine through the db_capsule 
>> wrapper call the same mysql_connect function.
>>
>> I have tried this with and without the php\ and Apache2\bin dirs in the 
>> path.
>>
>>
>> Suggestions?
>> -Jim Stapleton
>> -- 
>> PHP Windows Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>> 

--- End Message ---
--- Begin Message ---
If my understanding of SWITCH is correct, it stops at the first case that
matches the result, correct?

So then.. If I have a switch as such;

switch($qty){

case ($qty < 1600): //$qty is less than 1600
  do something
break;

case ($qty < 2400): //$qty is less than 2400
  do something
break;

case ($qty >= 2400); //$qty is greater than or equal to 2400
  do something
break;

default:
 do something
break;
}

Then assuming $qty = 800, it should stop at the first case? right?

a $qty of 1601 should stop at the second case?

and a qty of greater than or equal to 2400 should stop at the last case?

Am I correct with my switch statement then?

My desired result is;

If quantity is less than 1600 set price = whatever;
or if quantity is equal to 1600 and less than 2400 set price = whatever,
or finally if quantity is equal to or greater than 2400 set price =
whatever.

I'm having difficulties for whatever reason to come up with a proper
comparison
for the switch to work as described.  Can someone help me iron out this
small problem?


Much thanks for the help,

Tony D.

--- End Message ---
--- Begin Message ---
I just copy and pasted your switch statement and it worked fine for me
the way you described it needed to work.

One thing I did notice, there's a semi-colon on the >= 2400 CASE, but it
still seemed to work ok for me (maybe I noticed and fixed that before I
tested >= 2400).

What error are you getting or what results using what values for $qty?


One thing I'll point out that I didn't know before but someone on here
enlightened me to was that there's two ways to use switch, one where you
use switch($variable) and your case statements are what the $variable is
equal to, or you can use other kinds of conditions in your case
statement, then it doesn't really matter what your switch() contains:


Switch ($variable) {
   case 0:
      echo "zero";
      break;
   case 1:
      echo "one";
      break;
   default:
      echo "other;
      break;
}

Or...


Switch (TRUE) {
   case ($variable < 0):
      echo "Negative";
      break;
   case ($variable < 100):
      echo "Under 100";
      break;
   case ($variable < 1000):
      echo "Under 1000";
      break;
   default:
      echo ">= 1000";
      break;
}


You can leave out break statements if you want it to execute certain
things for multiple cases in an additive fashion:

$sendemail = TRUE;
$tofield = "";
$ccfield = "";
$bccfield = "";

Switch ($sendemail) {
   case ($bcc <> ""):
      $bccfield = LookupEmailAddresses($bcc);
   case ($cc <> ""):
      $ccfield = LookupEmailAddresses($cc);
   case ($to <> ""):
      $tofield = LookupEmailAddresses($cc);
      SendEmail($tofield,$ccfield,$bccfield);
      break;
   default:
      echo "No recipients, email not sent";
      break;
}

In this case, it only processes BCC, CC and TO fields if they contain
data.  You might just enter "Trevor" and it runs the function
LookupEmailAddresses to find "[EMAIL PROTECTED]" and inserts
that into the $bccfield variable.

Lastly, you can stack case clauses or use an OR operator to do something
when either condition is true:


Switch (TRUE) {
   case ($variable < 0):
   case ($variable >= 1000):
      echo "Out of range (either too large or too small)";
      break;
   case ($variable < 100):
      echo "Between 0 and 100";
      break;
   case ($variable < 1000):
      echo "Between 100 and 1000";
      break;
   default:
      echo "Some imaginary value";
      break;
}


You could also express that as:
   case ($variable < 0 OR $variable >= 1000):



I'm sure there are other ways to use Switch/Case.  I know you didn't ask
for a whole tutorial and stuff, but it's a good thing to know how to
use, very useful (and a lot nicer to play with than a bunch of nested
if/then/else's).

Did I screw anything up in those examples?  I'm sure someone will point
it out. Hah..  Any other creative uses for Switch that I missed?

-TG



> -----Original Message-----
> From: Tony Devlin [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, November 11, 2004 12:35 PM
> To: Php-Windows
> Subject: [PHP-WIN] Question concerning SWITCH and Comparisons
> 
> 
> If my understanding of SWITCH is correct, it stops at the 
> first case that
> matches the result, correct?
> 
> So then.. If I have a switch as such;
> 
> switch($qty){
> 
> case ($qty < 1600): //$qty is less than 1600
>   do something
> break;
> 
> case ($qty < 2400): //$qty is less than 2400
>   do something
> break;
> 
> case ($qty >= 2400); //$qty is greater than or equal to 2400
>   do something
> break;
> 
> default:
>  do something
> break;
> }
> 
> Then assuming $qty = 800, it should stop at the first case? right?
> 
> a $qty of 1601 should stop at the second case?
> 
> and a qty of greater than or equal to 2400 should stop at the 
> last case?
> 
> Am I correct with my switch statement then?
> 
> My desired result is;
> 
> If quantity is less than 1600 set price = whatever;
> or if quantity is equal to 1600 and less than 2400 set price 
> = whatever,
> or finally if quantity is equal to or greater than 2400 set price =
> whatever.
> 
> I'm having difficulties for whatever reason to come up with a proper
> comparison
> for the switch to work as described.  Can someone help me 
> iron out this
> small problem?
> 
> 
> Much thanks for the help,
> 
> Tony D.
> 

--- End Message ---
--- Begin Message ---
Yepp, that true, and thats why we have switch.
Otherwise switch would be syntactic suggar only. 

-----Original Message-----
From: Gryffyn, Trevor
To: Php-Windows
Cc: [EMAIL PROTECTED]
Sent: 11-11-2004 19:17
Subject: RE: [PHP-WIN] Question concerning SWITCH and Comparisons

One thing I'll point out that I didn't know before but someone on here
enlightened me to was that there's two ways to use switch, one where you
use switch($variable) and your case statements are what the $variable is
equal to, or you can use other kinds of conditions in your case
statement, then it doesn't really matter what your switch() contains:

--- End Message ---
--- Begin Message ---
Dear All,

When I add 'LoadModule php4_module C:/PHP/sapi/php4apache2.dll' to my Apache 
httpd.conf it does not want to start-up in XP. When I run it without it it 
starts up. Do I need this to execute php?

Apache 2.0.5
PHP4

R's

Will

--- End Message ---

Reply via email to