Click to See Complete Forum and Search --> : [RESOLVED] Somthing really stupid here ?


DMP23
04-06-2006, 11:43 AM
something really stupid going on here that i cant figure out. if i set $keyword == to a number and post in the corresponding number it will print OK, as its correctly posted in from the previous page BUT when i change the condition $keyword== a word (and post in the corresponding keyword, in this case det) it will not print OK... so im not sure if the the word (det) is posting correctly in from the previous page...plz advise

$keyword = $_POST["type1"];

if($keyword=="det"){
print OK;
}
else {print
Shamballs; }


as said above this test works ok with numbers being posted in as below :
$keyword = $_POST["response"];


//check if the keyword is empty
if($keyword=="1"){
print OK;
}
else {print
Shamballs; }

The Little Guy
04-06-2006, 12:16 PM
Im not sure if this is the problem, but don't you need quotes around OK, and Shamballs?

DMP23
04-06-2006, 12:23 PM
thanx for suggestion but alas it didnt work,put "" around both shamballs and OK ...

The Little Guy
04-06-2006, 02:40 PM
are these both in the same php file?

if so, try changing the second var to something else

chazzy
04-06-2006, 02:59 PM
when you say "it will not print OK" does this mean that it doesn't print anything or it prints out Shamballs?

NogDog
04-06-2006, 05:22 PM
Try a little debugging:

error_reporting(E_USER_NOTICE);
if(!isset($_POST['type1']) or $_POST['type1'] === "")
{
trigger_error("POST['type1'] is not set or empty.", E_USER_WARNING);
}
else
{
$keyword = $_POST["type1"];
if($keyword == "det")
{
print "OK";
}
else
{
print "Shamballs";
trigger_error("Value of POST['type1'] is: " . $_POST['type1'], E_USER_NOTICE);
}
}

DMP23
04-07-2006, 09:50 AM
hey thanx a mill for that error handeling , becauce i thru that piece of code in i identified where i was going wrong. everything is honky dorey now! :)