MadnessRed Posted June 25, 2008 Share Posted June 25, 2008 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 More sharing options...
revraz Posted June 25, 2008 Share Posted June 25, 2008 Why not change the background back to the original color? Link to comment https://forums.phpfreaks.com/topic/111907-problem-in-if-statement/#findComment-574392 Share on other sites More sharing options...
MadnessRed Posted June 25, 2008 Author Share Posted June 25, 2008 because original is no background also it doesn't matter what i change it to, its just that the if is not executing properly. if I go to brokensite.sql.php?id=2&act=fix it changes that row to broken ^ sorry I added that 6 secs after you posted Link to comment https://forums.phpfreaks.com/topic/111907-problem-in-if-statement/#findComment-574394 Share on other sites More sharing options...
kenrbnsn Posted June 25, 2008 Share Posted June 25, 2008 The comparison operator for equality is '==' not '='. Ken Link to comment https://forums.phpfreaks.com/topic/111907-problem-in-if-statement/#findComment-574486 Share on other sites More sharing options...
MadnessRed Posted June 26, 2008 Author Share Posted June 26, 2008 ok, thanks Link to comment https://forums.phpfreaks.com/topic/111907-problem-in-if-statement/#findComment-574976 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.