Can't get my final if statement to work

What happened when you tried?

1 Like

If you want to be a software engineer. You can’t just ignore advice by people who know what they talking about. When multiple people tell you to normalize / modify your database you should use their advice to grow, learn. Especially when someone takes the time to show you exactly how to do it. There are many people on your threads who know what they are doing. They are offering advice, assistance and you constantly choose to ignore it. Here is the thing… that does not change. If you are going to ignore well informed advice now and you will probably keep ignoring it. No one wants a intern or an entry level dev/programmer who is going to ignore things. I’m positive that everyone who has given you advice including the individual who redesigned your db architecture would rather who listen, apply the advice that was given then go ahead with your project and get it done. I will tell you right now that much of guidance you are getting on this forum would be the same advice you would get in a professional environment. It is absolutely fine you don’t know everything. I think most people are understanding to that. It is a complete other thing to ignore relevant advice. You know maybe you need to spend less time worrying about making your project work and more on being able to consume/listen to people and use what they tell you to improve and make what you are building acceptable within a professional atmosphere. I’m going to tell you right now that if you are ignoring people now you are going to do the same thing throughout you’re career. Beyond building some bs website learn to absorb information and use it to improve yourself. No one wants a developer who isn’t able/willing to learn and adapt to things/concepts they are being told. Lastly, I’m just going to say that the last think people look for in a dev is a functional website to show. Leads and people in charge of hiring other look for problem solving capabilities and openness to take critism and adapt/change given that info to improve their their skills.

4 Likes

I want to ask a real question. You have SO many post. So many people have responded. If you are not taking their advice then why are you apart of the community?

Typically you would use a loop when you fetch multiple rows from the database, so you process each row in turn.
If you only fetch a single row, there is no need for a loop, you process that single row alone…

That was me cutting down:-

if($subscriptionplan === 'Level 1' && date("Y-m-d") > $paidbydate && $activate == 1 && $emailreminder == 1) {

to:-

if($emailreminder == 1) {

…as the first 3 conditions of the 4 have already been met in an earlier if so are redundant.
But yes, if it’s a Boolean it could be shortened further.

I have read somewhere that the header must be placed immediately right after the if condition in order for it to work but then, where would I place my sql queries? On the other page?

Stop reading wherever that was. The key thing with header(), as has been mentioned several times, is that you cannot send anything to the browser before you call it, or it will not work and will give “headers already sent” errors.

1 Like

I don’t know where that idea comes from.
Headers must be before any output to the browser, but proximity to if conditions is not an issue AFAIK.

In this line of code

if ($subscriptionplan === 'Level 1' && date("Y-m-d") < $paidbydate && $paid == 1 && $activate == 1) {

which I think I’m correct in saying is the last if() statement that you are worried about, where does the value of $paid come from? I can’t see it anywhere in the rest of the code.

How have you determined that it is not executing this statement?

Found it, it’s in the mysqli_stmt_bind_result list.

And to answer my own question:-

If the if condition is not met, you get sent by the header redirect that precedes the if.
So you don’t need an else after the if closes (if that is the intended outcome), but it’s a very confusing logical structure to follow as it is.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.