Jump to content

problem in if statement


MadnessRed

Recommended Posts

All I want is that if $act = broken $new = ' #ff0000'

 

else $new = 'NULL'

 

then that goes into a database. here is my code

 

What happens is that if a user reports a link as broken it shows up a red for the admins. That works fine, but I want a good was to report something as not broken for an admin. here is my code.

 

// Broken info
$id = $_GET["id"];
$act = $_GET["act"];

// Lets it broken or not, if so colour is red, else its nothing
if ($act = "broke") {
$new = ' bgcolor=#FF0000';
} elseif ($act = "fix") {
$new = 'NULL';
} else {
$new = 'NULL';
}


// Lets connect
$con = mysql_connect($servername,$username,$password);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

// Lets select the database
mysql_select_db("$database", $con);

// Lets select the table
$tblsites = $prefix.'sites';

// Change the broken-ness
$query1 = "UPDATE `madnessred_sites` SET `Broken` = '$new' WHERE `ID` ='$id'";

mysql_query($query1, $con);

// Now lets leave the database
mysql_close($con);

 

If I go to

brokensite.sql.php?id=1&act=broke

 

The row goes red, perfect, however if I go to

brokensite.sql.php?id=1&act=fix

 

its stays red??

 

How do I fix that?

 

I have tried replacing 'NULL' with '' and ' ' but to no effect, the iff statement jsut seems to take the first option and then not bother.

 

Also if I go to

brokensite.sql.php?id=2&act=fix

it changes that row to broken, even though it should be changing it to fix, what is wrong with my if?

Link to comment
https://forums.phpfreaks.com/topic/111907-problem-in-if-statement/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.