php mysql_query insert in not working

advertisements
<form method="post" action="updatescreen(2).php">
Name of company:<br />
<input type="text" name="artid" id="artid" size="50" /><br /><br />
<input type="submit" name="Insert" id="Insert" value="Insert" /><br /><br />

<?php
if(isset($_POST['Insert'])){
    $id = $_POST['artid'];

    mysql_query("INSERT INTO test (id) VALUES ('$id', )");
}

?></form>

The connection to the database is included so not mentioned here. The connection is working fine, that's not the problem.

The problem is: the php code doesn't work. The php code doesn't insert the data into my database. What's wrong?


You had a , after '$id':

mysql_query("INSERT INTO test (id) VALUES ('$id')");

Your code is also open to SQL injection. You should be using something like PDO instead of the mysql_* functions, which are deprecated. With PDO, you can guard against SQL injections by using prepared statements.