当前位置: 代码迷 >> PHP >> 帮看下这段代码,插入数据库部分出有关问题,没找到异常
  详细解决方案

帮看下这段代码,插入数据库部分出有关问题,没找到异常

热度:98   发布时间:2016-04-28 19:24:25.0
帮看下这段代码,插入数据库部分出问题,没找到错误
<!DOCTYPE html>
<html>
        <head>
                <meta charset=utf-8/>
                <title>War-game -Add Your score</title>
        </head>
        <body>
                <h2>War game - add your score</h2>
                <?php
                        if(!empty($_POST['submit']))
                        {
                                $first_name=$_POST['first_name'];
                                $last_name=$_POST['last_name'];
                                $score=$_POST['score'];
                                echo $first_name;
                                echo $last_name;
                                echo $score;

                                $dbc=mysqli_connect('localhost','root','pengyu2408','score_list')or die('error in connet');
                                $query="INSERT INTO score_lis(first_name,last_name,score) VALUES('$first_name','$last_name','$score')";
                                mysqli_query($dbc,$query)or die('error_2');
                                echo '<p>Thanks for adding your new high score!</p>';
                                echo '<p><strong>FIRST_NAME:</strong>'.$first_name.'<br/>';
                                echo '<strong>LAST_NAME:</strong>'.$last_name.'</p>';
                                echo '<p><strong>Score:</strong>'.$score.'<br/></p>';
                                echo '<p><a href="index.php">&lt;&lt;Back to hight score</a></p>';
                                //clear the score data to clear the form
                                $firet_name="";
                                $last_name="";
                                mysqli_close($dbc);
                        }
                ?>
                <hr />
  相关解决方案