douzi6992 2014-09-30 15:01
浏览 52
已采纳

PDO sql查询没有执行,也没有进一步加载html内容

This PHP code is not printing anyhting and also not able to print the HTML beneath it as well....

The databases and the table are set up and running perfectly. but this query doesnt seem to execute.

<?php
  $db = new PDO('mysql:dbname=tipcc;host=localhost;charset=utf8', 'root', 'plsdonthack');

$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$stmt=$db->prepare ("INSERT INTO submissions (NAME,TIME,MEMORY,LANG,LINK)
                    VALUES
                        (:name,:time,:memory,:lang,:link)");

    $stmt->bindParam (':name',$_COOKIE['user'], PDO::PARAM_STR);
    $stmt->bindParam (':time',$details['time'], PDO::PARAM_STR);
    $stmt->bindParam (':memory',$details['memory'], PDO::PARAM_STR);
    $stmt->bindParam (':lang',$details['langName'], PDO::PARAM_STR);
    $stmt->bindParam (':link',$details['link'], PDO::PARAM_STR);

            if ($stmt->execute ())
            {
                echo "hoel";
            }
            else
            {
                echo "loal";
            }
?>
// Some HTML Below.

Error Report :

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'LINK' cannot be null' in /var/www/html/TIP-CC/my_php2.php:171 Stack trace: #0 /var/www/html/TIP-CC/my_php2.php(171): PDOStatement->execute() #1 {main} thrown in /var/www/html/TIP-CC/my_php2.php on line 171

  • 写回答

1条回答 默认 最新

  • drt96856 2014-10-01 17:40
    关注

    Answer is simple:

    I had to use the return value of the function. I was using the IDEONE API incorrectly.

    $result = $client->createSubmission( $user, $pass, $input_code, $lang, $input_data, $run, $private );

    and use it as $result['link']

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等