提交表单时Mysqli表未更新如何解决?

问题描述

这是无法更新数据库表的代码

MysqLi_query($connect,"UPDATE questions1 SET Votes='$newVotes' WHERE rateid='$rateid' AND question1='$rateoption'");
                            MysqLi_query($connect,"UPDATE rates1 SET ipaddress='$newipaddress' WHERE rateid='$rateid'");

这是我的完整代码

<?PHP
    
        $rateid = $_GET['rateid'];
            $connect = MysqLi_connect('localhost','root','','rate');
            $query = "SELECT * FROM rates1 WHERE rateid='$rateid'";
            $q = MysqLi_query($connect,$query);
            while($row = MysqLi_fetch_array($q)) {
                $id = $row[0];
                $title = $row[1];
                $rateid = $row[2];
                $ipaddress = $row[3];
                echo "<h1 id = 'lmk'>$title</h1><br>";
                ?>
                <table>
                    <form action="" method="POST">
                <?PHP
                    $questions = "SELECT * FROM questions1 WHERE rateid='$rateid'";
                    $q2 = MysqLi_query($connect,$questions);
                    while($r = MysqLi_fetch_array($q2)) {
                    $question = $r[1];
                    $Votes = $r[2];
                    $newVotes = $Votes + 1;
                    $ip = $_SERVER['REMOTE_ADDR'];
                    $newipaddress = $ipaddress."$ip,";
    
                    if (isset($_POST['rate'])) {
                        $rateoption = $_POST['rateoption'];
                        if ($rateoption == "") {
                            die('<div class= "blm">' . "You didn't select an option." . '<br><br>' . '</div>');
                        } else {
    
                                $ipaddresse = explode(",",$ipaddress);
                                if (in_array($ip,$ipaddresse)) {
                                    die('<div class= "blm">' . "You've already rated" . '<br><br>' . '</div>');
                                } else {
                            MysqLi_query($connect,"UPDATE rates1 SET ipaddress='$newipaddress' WHERE rateid='$rateid'");
                            die('<div class= "blm">' . "Your rating was casted successfully" . '<br><br>' . '</div>');
                            }
                        }
                    }**
                    '<div class = "mnbh">';
    
                    echo '<tr><td><div class ="loij">'.$question.'</div></td><td><div class = "lopk"><input type="radio" name="rateoption" value="'.$question.'" /><div class = "mnbv"></div></div></td></tr>';
                    }
            }
    ?>
    
      <tr><td><br><br><div class="cogat"><input type = "submit" name = "rate" value = "Submit"></div></td></tr>
    </div>
    </div>
    </div>
    
    </form></table>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)