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']

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

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)