Trying to insert into database using id from link and prepared statement
<p>I currently have the following code. What I'm trying to do is fetch the <code>oppdrID=x</code> from the link and put the query into the row with the same <code>oppdrID</code>. I can't get it to work because something is not working. What am I dong wrong here?</p>

<pre><code>&lt;!doctype html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;link rel="stylesheet" type="text/css" href="stilsett.php" /&gt;
&lt;meta charset="utf-8"&gt;
&lt;title&gt;Endre oppdrag // Prosjekt - PHP&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;?php
include "funksjoner.inc.php";
session_start();
if(!empty($_SESSION['brukernavn'])) {

echo "&lt;div id='header'&gt;";

echo navigasjon();

echo "&lt;/div&gt;";

echo "&lt;div id='innhold'&gt;";

$startTid = mysqli_real_escape_string(kobleTil(),  htmlspecialchars($_POST['startTid']));
$slutTid = mysqli_real_escape_string(kobleTil(),  htmlspecialchars($_POST['slutTid']));
$merknad = mysqli_real_escape_string(kobleTil(), htmlspecialchars($_POST['merknad']));
$antTimer = mysqli_real_escape_string(kobleTil(), htmlspecialchars($_POST['antTimer']));

if ($startTid == '' || $slutTid == '' || $merknad == '' || $antTimer == '')  {

$error = "Vennligst fyll inn alle dataene!";

}

$db = kobleTil();
if (isset($_GET['oppdrID']) &amp;&amp; is_numeric($_GET['oppdrID']) &amp;&amp;   $_GET['oppdrID'] &gt; 0) {

$id = $_GET['oppdrID'];

$sql = "INSERT INTO timeregistrering WHERE oppdrID = ? (startTid, sluttTid,  merknad, timer) values ('$startTid', '$slutTid', '$merknad', '$antTimer');
";

if ($stmt-&gt;prepare($sql)) {

$stmt-&gt;bind_param("i", $id, $startTid, $slutTid, $merknad, $antTimer);
$stmt-&gt;execute();

if ($db-&gt;query($sql)) {

    echo "&lt;p&gt;&lt;b&gt;Tabellen ble opprettet!&lt;/b&gt;&lt;/p&gt;";
    echo "&lt;b&gt;Spørringen som ble kjørt:&lt;/b&gt;&lt;pre&gt;$sql&lt;/pre&gt;";

    } else {

    echo "&lt;p&gt;Noe gikk galt :(&lt;/p&gt;" . $error;
        }
    }
    }
}

echo "&lt;/div&gt;";

?&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>