PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Yes, this is a homework assignment. I have spent 20 hours trying to figure this one (and one other similar one) out and I am not asking that you do it but if you could give me a hint! I can't get it to move onto the ELSE part of the code. I am sure it it something silly but after all these hours I am burning out. Your help would be greatly appreciated.
I see one error as I review this, again. As I moved the is_numeric together, I missed the preg_match pattern for the three variables. Would it be better to use a different function to make sure they are numeric?
Ok... I am down to fixing the preg_match to be sure the 0 is not entered. I broke them down into three if statements but they still are kicking back error messages "Warning: preg_match(): Empty regular expression" . I have everything else working. Any help?
You lost me. I know the validation still isn't right but I got the rest working. I submitted the assignment as it was but any help in understanding this for the future would be helpful. I fixed my "double negative by removing the ! from the preg_match. This removed the error messages but it still doesn't stop the script if there is an error.
Why are you using regex to determine if the number is positive? Is that a requirement of the assignment? Makes more sense and is more efficient to check if the number is greater than 0. That would also allow you to remove the third comparison (which is currently an assignment and not a comparison).