gsmith

msg:4098462 | 1:30 am on Mar 16, 2010 (gmt 0) |
Could it be that an unexpected value of $g is being input? Instead of the series of "if" statements, why not try if () {} else if () {} ... else {something that would notify you of an unexpected value}
|
smallcompany

msg:4098581 | 7:00 am on Mar 16, 2010 (gmt 0) |
| Could it be that an unexpected value of $g is being input? |
| No. I use proven link and get redirects onto two different locations: expected and unexpected. Please note that the unexpected happens only occasionally, can't really measure it. Thanks
|
Anyango

msg:4098603 | 7:47 am on Mar 16, 2010 (gmt 0) |
is the value for $g trimmed ? could it be due to some white space that ocassionaly is there in its value? just a guess
|
gsmith

msg:4098731 | 1:17 pm on Mar 16, 2010 (gmt 0) |
You have to use the "if else" control structure in order to prove that things are working as expected, and to handle the unexpected.
|
jatar_k

msg:4098763 | 2:04 pm on Mar 16, 2010 (gmt 0) |
you could add a log to record values when the default case is hit
|
smallcompany

msg:4100069 | 2:58 am on Mar 18, 2010 (gmt 0) |
Thanks. I just experienced a few in a raw. I'm not sure if IE 8 could play a role here since it's PHP (server side). Anyhow, then I changed the "empty" value from this: $link="http://www.example.com/"; //this is if the variable is not found to this form: if ($g == "") {$link = "http://www.example.com/";} As I could see it, it was still empty, but in more defined form. It worked right after I applied this change. Do you agree that the two versions of empty value differ? Thanks
|
Anyango

msg:4101439 | 7:20 am on Mar 20, 2010 (gmt 0) |
Yep the two versions are different imho. Your first version, which is
$link="http://www.example.com/"; //this is if the variable is not found if ($g == "link1") {$link = "http://www.example.com/";} if ($g == "link2") {$link = "http://www.example.com/";} if ($g == "link3") {$link = "http://www.example.com/";}
allows for 4 different values, link1,link2,link3, and "everything else" and your second code, allows for 5 different values link1,link2,link3,empty, and "everything else". Just an opinion on the question, not any explanation of whats going on :)
|
smallcompany

msg:4101640 | 8:05 pm on Mar 20, 2010 (gmt 0) |
and your second code, allows for 5 different values link1,link2,link3,empty, and "everything else". |
| Thanks. Are you saying that if ($g == "") {$link = "http://www.example.com/";} is both "empty" and "everything else"?
|
Anyango

msg:4102147 | 6:06 am on Mar 22, 2010 (gmt 0) |
its like this $link="http://www.example.com/"; //this is if the variable is not found if ($g == "link1") {$link = "http://www.example.com/";} if ($g == "link2") {$link = "http://www.example.com/";} if ($g == "link3") {$link = "http://www.example.com/";} if ($g == "") {$link = "http://www.example.com/";} 1st value, when g is "link1" 2nd value, when g is "link2" 3rd value, when g is "link3" 4th value, when g is "" 5th value, when g is niether of the above 4 if ($g == "") {$link = "http://www.example.com/";} is only when empty but in that code the 5th value is not being taken care of. Thats why an elseif structure would be more suited cause it would take care of all the 5 possible values. if(g is empty) elseif(g is link1) elseif(g is link2) elseif(g is link3) elseif(g is link4) else(this else covers "everything else") That way you wont have unexpected outputs, 1 of your 5 provided links will always be there.
|
|