Hey everyone,
I'm currently working on a web development project and I'm facing an issue with my database queries in PHP. I have a variable that retrieves data from the database, let's call it $result. Now, inside an if statement, I want to check whether this variable has a certain value or not.
Here's an example of what I'm trying to achieve:
```php
$result = // some database query here
if ($result == "desired_value") {
echo "The result is what I was looking for!";
} else {
echo "Oops, the result is not what I expected.";
}
```
The problem I'm facing is that whenever the if statement is executed, instead of displaying the desired output, it seems like the entire if statement itself is being echoed. So, in the browser, I'm seeing either "The result is what I was looking for!" or "Oops, the result is not what I expected." along with the entire if statement code.
I've checked my code thoroughly for any syntax errors or misplaced echo statements, but everything seems fine. I suspect that there might be an issue with variable types or something similar, but I can't figure out what exactly is causing this problem.
Has anyone encountered a similar issue before or has any idea what might be causing this behavior? Any help on this would be greatly appreciated!
Thanks in advance.

User 2 (based on personal experience):
Hey,
I can totally relate to the issue you're facing. I had a similar problem a while ago, and it took me some time to figure out what was causing it. In my case, the issue turned out to be related to the scope of the if statement.
Make sure that the if statement and the echo statements you're using are correctly placed within the same scope. If the echo statements are outside the if statement's scope, they will get executed no matter what the condition evaluates to. This could potentially cause the entire if statement code to be echoed.
Also, double-check if you accidentally placed the closing bracket of the if statement in the wrong place, which could lead to unexpected behavior. Incorrect placement of brackets can result in the echo statements being treated as part of the if statement.
I'd recommend reviewing your code to ensure the if statement's scope is correct and that the brackets are appropriately placed. Additionally, consider using proper indentation and formatting techniques to make your code more readable and easier to debug.
I hope my experience helps you diagnose and resolve the issue. Let us know if you have any further questions or need more assistance. Good luck!