Re: [PHP] peer code review wanted

2002-04-15 Thread Erik Price


On Monday, April 15, 2002, at 04:58  PM, Robert Cummings wrote:

> Well you don't return true anywhere... default return is false which is
> what happens if the else statement is reached.

EUREKA!  Thanks so much Rob!  I too busy wondering how the preg_match 
was failing to notice that I didn't even have a return true!

Now, back to work.  I can stop fuming around the room.


Erik








Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] peer code review wanted

2002-04-15 Thread Robert Cummings

Erik Price wrote:
> 
> Hi, I am just not seeing what is wrong with my code.
> 
> Can anyone tell me if there is anything wrong with the following
> function?
> 
> function set_material_id($material_id)
> {
> if (!preg_match('/^\d{1,3}$/', $material_id)) {
> return false;
> } else {
> $this->ff_material_id = $material_id;
> }
> }
> 
> The value being passed to this function is "1" (contained in a POST form
> field named "ffmaterial0"), yet it is returning false.  I have a test in
> my script that looks like this:
> 
> } elseif
> (!$ff_instance->set_material_id($_POST["ffmaterial{$ff_counter}"])) {
> die("set_material_id() method of \$ff_instance failed");
> 
> And I am getting the "die()" error message.  $ff_counter is 0, the first
> iteration of a for loop.
> 
> Can anyone see a problem with this, or at least confirm that I'm not
> crazy?

Well you don't return true anywhere... default return is false which is
what happens if the else statement is reached.

Cheers,
Rob.
-- 
.-.
| Robert Cummings |
:-`.
| Webdeployer - Chief PHP and Java Programmer  |
:--:
| Mail  : mailto:[EMAIL PROTECTED] |
| Phone : (613) 731-4046 x.109 |
:--:
| Website : http://www.webmotion.com   |
| Fax : (613) 260-9545 |
`--'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] peer code review wanted

2002-04-15 Thread Erik Price

Hi, I am just not seeing what is wrong with my code.

Can anyone tell me if there is anything wrong with the following 
function?

function set_material_id($material_id)
{
if (!preg_match('/^\d{1,3}$/', $material_id)) {
return false;
} else {
$this->ff_material_id = $material_id;
}
}

The value being passed to this function is "1" (contained in a POST form 
field named "ffmaterial0"), yet it is returning false.  I have a test in 
my script that looks like this:

} elseif 
(!$ff_instance->set_material_id($_POST["ffmaterial{$ff_counter}"])) {
die("set_material_id() method of \$ff_instance failed");

And I am getting the "die()" error message.  $ff_counter is 0, the first 
iteration of a for loop.

Can anyone see a problem with this, or at least confirm that I'm not 
crazy?


Erik






Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php