PDO sql query fails and does not load html content further down

This PHP code doesn't print anything, nor can it print HTML underneath it.

The databases and table are set up and working fine. but this request doesn't seem to be fulfilling.

<?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.

      

Bug 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

+3


source to share


1 answer


The answer is simple:

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

.



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

and use it like $result['link']

0


source







All Articles