dongxian3574 2014-05-02 05:12
浏览 6
已采纳

查询wongt输出到表。 正确的语法

What am i doing wrong here? (Know its mysql) this else is not working it look like. user can insert same modul id many times.

$besvarelse = $_GET['besvarelse'];
$modulid = $_GET['modulid'];
$username = $_GET['username'];

$tilkobling = kobleTil(); 
if (!empty($besvarelse) ) {
      $insert = mysql_query("INSERT INTO oppgave (besvarelse, modulid, username) VALUES ('$besvarelse', '$modulid','$username')");


if($insert) {

          echo "<h1>Levering OK</h1><br>";

        }
    }
    else {

        die("<h1>Du har lever før</h1>");

    }
?>
  • 写回答

2条回答 默认 最新

  • duandai0373 2014-05-02 05:22
    关注

    Try with this and post the errors that PHP shows, please:

    //Assuming that connection to mysql server its done somewhere with mysql_connect()
    
    error_reporting(E_ALL); ini_set('display_errors', 1);
    explode($_GET);
    
    echo "<pre>";
    print_r($_GET); //Just to see what's on the variables...
    echo "</pre>;
    
    // $tilkobling = kobleTil(); Need to explain this line
    
    if (!empty($besvarelse) ) {
    $sql = "INSERT INTO oppgave (besvarelse, modulid, username) VALUES ('$besvarelse', '$modulid','$username')";
    
    if($insert = mysql_query($sql))
           {
              echo "<h1>Levering OK</h1><br>";
    
            }
    
        else {
    
            die("<h1>Du har lever før</h1>");
    
        }
    } // you were missmatching the IF closing bracket
    
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效