Thanks to Karen and Richard for your help!
I removed the quotes around 0 in the comparison for mysql_affected_rows.
That was definitely important.
I then added the echo $sql; statement Richard recommended, and saw the
following:
(save some time and just look at the end of the string)
SELECT * FROM contact_info WHERE zipcode='86345' AND
email="[EMAIL PROTECTED]"&result=Fail&errorMsg=We+do+not+have+the+given+email+and+zi
pcode+on+file.++Please+go+to+the+menu+and+start+again.&result=Edit
I had completely missed that! That was overriding my &result=Fail earlier
in the string, so naturally it was going to the edit page. Doh!
Looking thru my code I had a hard time figuring it out (although it's seems
simple now):
1 function getEditData($email,$zipcode) {
2 $sql = "SELECT * FROM contact_info WHERE zipcode='$zipcode' AND
email=\"{$email}\"";
3 echo $sql;
4 $query = mysql_query($sql);
5 if (mysql_affected_rows()==0) {
6 $this->sendResult("Fail","We do not have the given email and zipcode
on file. Please go to the menu and start again.");
7 } else {
8 //a bunch of variables declared here so I pulled them out for space
9 $this->sendResult("Edit",$varsToEdit);
10 }
Even though I was invoking the function sendResult for the failure, the code
was continuing on to the NEXT sendResult which was giving the Edit message.
Here is the sendResult function:
11 function sendResult($result,$txtMsg) {
12 switch ($result) {
13 case "Okay":
14 $txtMsg = urlencode($txtMsg);
15 print "&result=Okay&successMsg=" . $txtMsg;
16 break;
17 case "Fail":
18 $txtMsg = urlencode($txtMsg);
19 print "&result=Fail&errorMsg=" . $txtMsg;
20 break;
21 case "Edit":
22 print "&result=Edit&" . $txtMsg;
23 break;
24 }
25 }
So result was being sent twice, and the second value(sent on line 22) for
result overrode the first (on line19)!!!! The Solution? Add a break;
inside the first "if" after line 6. Problem solved because the script stops
(which it should at that point).
WOW, I hope you guys don't mind me sharing all of that, maybe it will help
somebody else in the future - make sure you terminate your failure cases if
you're calling another function to handle the job.
Thanks again for the help :)
Kirk
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php