If statement not working as expected

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: If statement not working as expected

Post by requinix »

Code: Select all

if (!$user_theme == $_SESSION["user_theme"]) {
What that says is to take $user_theme, negate it, then compare with the session data.

Want a not-equals? Use the not-equals sign.

Code: Select all

if ($user_theme != $_SESSION["user_theme"]) {
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: If statement not working as expected

Post by requinix »

Oh.

You didn't name your select. Giving it an ID is a different thing.

Code: Select all

<select id="user_theme" name="user_theme">
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: If statement not working as expected

Post by requinix »

Wargog wrote:Ugh, I knew there was something wrong, I keep forgetting when to use id, name, class etc.
The id is completely client-side. You can use it for anchors (#foo) and Javascript.
The name can be used client-side too with Javascript, but its most common purpose is to give form fields the name they should use with submitting the form, and thus how you receive their data.
The class is primarily for CSS but can be useful with Javascript too.
Wargog wrote:Ok, it's receiving the data and prints a blank page and doesn't write the result to SQL, but hey, no errors right?
Since the error messages work, there may a fatal error somewhere. Check your error logs. I also suggest turning on display_errors (for your development environment only).
Post Reply