Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble with 'IF'

Status
Not open for further replies.

wudz

Programmer
Mar 28, 2001
135
GB
Sorry to post this what should be a simple compare, but just can not get the result that I expect and I don't understand why!

$payment=mysql_result($res_,0,"payment");

if ($payment == "Paypal"){
$payment=$MSG_888;
} else {
$payment="";
}
It always returns an empty, yet if I comment out the IF and echo $payment query it shows "Paypal" and case is correct and matches what I want to compare...Thought I was understanding what I was doing most of the time, but this has got me screaming..

Cheers
John
 
maybe the problem is what is assigned to $MSG_888? often these capitalised bits are defined terms (DEFINE...) rather than variables.
 
Hi again jpadie,

Well I was wondering something on that line so I commented out all and just allowed
$payment=$MSG_888;
which did return the correct message in the email, where the finished logic ends up.
I also commented out all the If statement and just left
$payment=mysql_result($res_,0,"payment");
and this showed Paypal in the email.
I then tried
$payment=(strlen($payament));
and it just showed a small box in the email....really stumped!

Oh, many thanks for you speedy response,,,Great!

Cheers
John

 
Just done another test setting the variable.

$payment=mysql_result($res_,0,"payment");

$payment ="Paypal";
if ($payment== "Paypal"){
$payment=$MSG_888;
} else {
$payment="";
}
Now the if statement works...how is that, can the queried $payment look correct or has it got some trailing hidden stuff attached....just grabbing stardust or what!

Hope this may throw some light on the problem..

Cheers
John
 
try this as a test:
[trim]
$payment=trim(mysql_result($res_,0,"payment"));
 
YOU are my MASTER......GREAT.
I have faffed about with this for two hours thinking it would take 5 mins....

Well what had I done wrong..I did a quick test before your answer where I placed the word test in the email immediatly after the printed result of just Paypal and it was thrown onto the next line as though there was an embedded <BR> or loads of spaces...
Anyway what ever was there ain't causing any more grief..

Thanks a bunch jpadie, yet again..

Cheers

John

PS. Sorry to all the PHP lads on the forum for my basic problems, I am trying to learn as quick as I can, let's hope sometime in the near future things improve at this end..
 
i guess there was some extra stuff appended to the data in the db. trim removes the whitespace from the beginning and end of a variable.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top