Hi guys,

having a bit of trouble with the following piece of code,

<?php
if (strcmp($pubinfo_username, $_SESSION['username'] ) == 0) {
echo "<img alt=\"Remove this post\" height=\"20\" src=\"../images/btns/x.png\" width=\"25\">";
}
?>

What I need this code to do is compare the string from the variable $pubinfo_username and compare it with the session stored username, It theoretically should work but doesn't, If there is a match then it returns 0 being TRUE and then show the remove button. But this code does not seem to work.

Any ideas?
Any help much appreciated!

Jack

Recommended Answers

All 2 Replies

Just use:

if ($pubinfo_username == $_SESSION['username'])

I don't see why binary compare is required in this case.

I tried your code and is working fine, perhaps one of the veriables is always coming up empty during comparison (are you sure your session is started). Share some more of the code, please.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.