Re: [PHP-WIN] Arrays past to functions

2007-07-27 Thread M. Sokolewicz
Niel Archer wrote: Hi hi Niel, I believe Jacob wanted to know how he could calculate the tax for _all_ states passed in as an array in one go. Yours simply gives it for 1 State ("locale"). Other than thatm $taxRate($state) translates to Array($state) which gives an E_FATAL_ERROR obviously.

Re: [PHP-WIN] Arrays past to functions

2007-07-27 Thread Niel Archer
> I must say, you're the first (and only) person I've ever seen using > foreach(): endforeach in PHP. As far as I know, most people use > curly-bracers (in this case), I'm sure most people wouldn't even know > this was possible (I had to look it up in the manual, and it's only in a > single not

Re: [PHP-WIN] Arrays past to functions

2007-07-27 Thread Niel Archer
Hi > hi Niel, > > I believe Jacob wanted to know how he could calculate the tax for _all_ > states passed in as an array in one go. Yours simply gives it for 1 > State ("locale"). Other than thatm $taxRate($state) translates to > Array($state) which gives an E_FATAL_ERROR obviously. I assume y

Re: [PHP-WIN] Error: illegal character I need help

2007-07-27 Thread Stephen
Even after changing the code it still does not work correctly and I'm still getting the same erroe. When I check the error logs for the Apache server I get this. [Thu Jul 26 19:56:57 2007] [error] [client 192.168.0.102] PHP Parse error: syntax error, unexpected '[' in C:\\Program Files\\Apache

Re: [PHP-WIN] Arrays past to functions

2007-07-27 Thread M. Sokolewicz
Niel Archer wrote: Hi Jacob. Spotted another problem. function compute_salestax ($Amount , $State) { $taxRate = array("CA" => 5 , "WA" => 7, "OR" => 8); return $Amount / 100 * $taxRate($State); } $payment = 1500; $locale = 'CA'; print "Tax on $amount in $locale is " . compute_salesta

Re: [PHP-WIN] Arrays past to functions

2007-07-27 Thread Niel Archer
Hi Jacob. Spotted another problem. function compute_salestax ($Amount , $State) { $taxRate = array("CA" => 5 , "WA" => 7, "OR" => 8); return $Amount / 100 * $taxRate($State); } $payment = 1500; $locale = 'CA'; print "Tax on $amount in $locale is " . compute_salestax ($payment , $locale

RE: [PHP-WIN] Arrays past to functions

2007-07-27 Thread Jacob Bergman
Thanks a bunch guys, I'm out for the day, I will pick this back up on Monday, have a great weekend. Jacob Bergman Network Technician Pullman School District #267 (509) 432-4012 [EMAIL PROTECTED] -Original Message- From: Niel Archer [mailto:[EMAIL PROTECTED] Sent: Friday, July 27, 2007 11

Re: [PHP-WIN] Arrays past to functions

2007-07-27 Thread Niel Archer
Hi Jacob Sorry, my fault entirely. I wrote it in a hurry after copy/pasting your example. I didn't change the variable names properly or test it. I still haven't been able to test, but this should work better now. function compute_salestax ($Amount , $State) { $taxRate = array("CA" => 5 , "W

Re: [PHP-WIN] Arrays past to functions

2007-07-27 Thread M. Sokolewicz
Ok, then let's start from the top: 1. foreach Foreach is a language construct used to loop over an entire array returning the (key and) value on each iteration. So: $a = array('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5,'f'=>6); foreach($a as $key=>$value) { echo $key.' = '.$value; } will return a=1

RE: [PHP-WIN] Arrays past to functions

2007-07-27 Thread Jacob Bergman
I tried using that, but all I get is these errors: Notice: Undefined variable: amount in C:\xampp\htdocs\test3.php on line 16 Fatal error: Function name must be a string in C:\xampp\htdocs\test3.php on line 11 Jacob Bergman Network Technician Pullman School District #267 (509) 432-4012 [EMAIL PR

RE: [PHP-WIN] Arrays past to functions

2007-07-27 Thread Jacob Bergman
Thanks, unfortunately, I don't really know what the whole " if(is_array($State)) { $total = 0; foreach($State as $s) { $total += ComputeSalesTax($Amt, $s); } return $total;" don't know enough yet to understand what all that means... I h

[PHP-WIN] Re: Apache copnfig

2007-07-27 Thread zerof
Jacob Bergman escreveu: Hello all, I am new to this list as well as new to PHP, I want to start by saying thank you in advanced to everyone that will provide help for me in the future :-) I am learning how to use PHP with MySQL and Apache, running on a windows box. I am under the impression

Re: [PHP-WIN] Arrays past to functions

2007-07-27 Thread Niel Archer
Hi Jacob try this: function compute_salestax ($Amount , $State) { $taxRate = array("CA" => 5 , "WA" => 7, "OR" => 8); return $Amount * $taxRate($state); } $payment = 1500; $locale = 'CA'; print "Tax on $amount in $locale is " . compute_salestax ($payment , $locale); --

Re: [PHP-WIN] Arrays past to functions

2007-07-27 Thread M. Sokolewicz
function ComputeSalesTax($Amt, $State) { if(is_array($State)) { $total = 0; foreach($State as $s) { $total += ComputeSalesTax($Amt, $s); } return $total; } else { switch ($State) { case "CA"

RE: [PHP-WIN] Arrays past to functions

2007-07-27 Thread Jacob Bergman
Your right, and I have gotten it to work that way, but I wanted to see how it would be done if I was to use an array. I was trying to do something easy just so I could "see how it would be done" I guess you could say. Plus when I run the function, I want it to output the total price for all state

Re: [PHP-WIN] Arrays past to functions

2007-07-27 Thread Jarrett Meyer
You don't really need an array here. function ComputeSalesTax($Amt, $State) { switch ($State) { case "CA": $tax = 1.05; break; case "WA": $tax = 1.07; break; // etc. default: $tax = false; }

[PHP-WIN] Arrays past to functions

2007-07-27 Thread Jacob Bergman
Hello all, I am learning about passing arrays to functions, and am trying to create a function that will display a total amount for a price for several states. Say using CA, WA, and OR, and setting there tax rates at, whatever, say 5%, 7%, and 8% respectively. I want a function I can pass the a

Re: [PHP-WIN] n00b cannot start MySQL

2007-07-27 Thread Kevin Smith
Try telnet'ing on port 3306, which is the default port that MySQL runs on. Abhisek Dutta wrote: I am an extreme n00b here in PHP. just started learning PHP. Can't start MySQL. The command-prompt says: /Can't connect to MySQL server on 'localhost./ 'telnet localhost 10061' gives: /Connecting to

Re: [PHP-WIN] n00b cannot start MySQL

2007-07-27 Thread Carlton Whitehead
Abhisek, On the MySQL Server, open Task Manager -> Processes tab -> View -> Select Columns and enable PID. Find the Process ID for your mysqld-nt.exe (that is how it's named on my server). On the command prompt, do: netstat -abo Copy the netstat results into Notepad, and search for your mysql

[PHP-WIN] n00b cannot start MySQL

2007-07-27 Thread Abhisek Dutta
I am an extreme n00b here in PHP. just started learning PHP. Can't start MySQL. The command-prompt says: /Can't connect to MySQL server on 'localhost./ 'telnet localhost 10061' gives: /Connecting to localhost...Could not open connection to the host, on port 10061: Connect failed./ But 'services