Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Stupid If Statement. Should work, but it doesn't...
Old 11-17-2009, 05:24 PM Stupid If Statement. Should work, but it doesn't...
Physicsguy's Avatar
404 - Title not found

Posts: 920
Name: Scott Kaye
Location: Ontario
Trades: 0
Hi all,

I've made an incredibly simple if statement. All it does is check if a URL parameter is a certain value, and according to that, display certain content.

PHP Code:
<?php 
$currentURL 
"/userreview.php?reviewID=$reviewID";
$CommentingStatus $_GET["comments"];


  if (
$CommentingStatus "on") {
    echo 
"<a href='$currentURL&comments=off'>Turn Off Comments</a>"
  }
  else if (
$CommentingStatus "off") {
    echo 
"<a href='$currentURL&comments=on'>Turn On Comments</a>"
  }   
  else {
    echo 
"Parameter 'Comments' must be set to either 'on' or 'off'.";
  }

?>
I don't know why that won't work. It always displays 'Turn Off Comments', even if comments are already off!

It's supposed to:

Check if 'comments' is on or off.
If the comments are off, ask to turn them on.
Else if the comments are on, ask to turn them off.

Simple? Apparently not...?
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-17-2009, 05:34 PM Re: Stupid If Statement. Should work, but it doesn't...
rednimaT's Avatar
Skilled Talker

Posts: 64
Name: Taminder B.
Location: San Jose, CA
Trades: 0
you need a double = sign

Code:
<?php
$currentURL = "/userreview.php?reviewID=$reviewID";
$CommentingStatus = $_GET["comments"];


  if ($CommentingStatus == "on") {
    echo "<a href='$currentURL&comments=off'>Turn Off Comments</a>"; 
  }
  else if ($CommentingStatus == "off") {
    echo "<a href='$currentURL&comments=on'>Turn On Comments</a>"; 
  }   
  else {
    echo "Parameter 'Comments' must be set to either 'on' or 'off'.";
  }

?
__________________

Please login or register to view this content. Registration is FREE

(HTML/PHP/MySQL/JavaScript/AJAX/SEO)
rednimaT is offline
Reply With Quote
View Public Profile Visit rednimaT's homepage!
 
Old 11-17-2009, 05:35 PM Re: Stupid If Statement. Should work, but it doesn't...
Physicsguy's Avatar
404 - Title not found

Posts: 920
Name: Scott Kaye
Location: Ontario
Trades: 0
D'oh! Thanks!
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 11-17-2009, 06:13 PM Re: Stupid If Statement. Should work, but it doesn't...
rednimaT's Avatar
Skilled Talker

Posts: 64
Name: Taminder B.
Location: San Jose, CA
Trades: 0
no problem
__________________

Please login or register to view this content. Registration is FREE

(HTML/PHP/MySQL/JavaScript/AJAX/SEO)
rednimaT is offline
Reply With Quote
View Public Profile Visit rednimaT's homepage!
 
Reply     « Reply to Stupid If Statement. Should work, but it doesn't...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.20161 seconds with 12 queries