drrqwokuz71031449 2015-08-28 13:42
浏览 66

无法更新MySql数据库

  1. Objective is to change value of regStatus of table registration to 'd' from 'a'

  2. I was trying to update MySql table using following code nothing happens

User.php:

<?php
if($r_regStatus == 'a'){
echo "<a href='option2.php?r_id=$r_id&r_regStatus=$r_regStatus'> Deactivate</a>";
} else {
echo "<a href='option2.php?r_id=$r_id&r_regStatus=$r_regStatus'> Activate</a>";
}
?>

option2.PHP
------------
<?php
include 'connect.php'; 
include 'functions.php';
$r_id = $_GET['r_id'];
$regStatus = $_GET['r_regStatus'];
if($regStatus == 'a'){
 mysql_query("UPDATE `registration` SET `regStatus`='d' WHERE `id`='$r_id'");
 echo  mysql_query("UPDATE `registration` SET `regStatus`='d' WHERE `id`='$r_id'");
   header('location:registration.php');

   } else if($regStatus == 'b') {
 mysql_query("UPDATE `registration` SET `regStatus`='a' WHERE `id`='$r_id'");
  header('location:registration.php');
} 
?>
  • 写回答

1条回答 默认 最新

  • duanlu6114 2015-08-28 14:20
    关注

    You should use

    if($regStatus === 'a')
    

    and

    else if($regStatus === 'b')
    

    Also, check with echo that you have the values you think you have in $regstatus and $r_id

    评论

报告相同问题?