Matthias Lassnig Matthias Lassnig - 1 year ago 131
SQL Question

MySQL insert statement with PHP PDO

I need to write a PHP script using a database for school. Since my MySQL skills are currently dying, I would like to ask following question:
Following problem: I need to insert 'upload' at a specific 'ID' into my table. It should make something like this:
insert into PHP_Project() where ID = ;

$pdo = new PDO($this->dsn, $this->username, $this->password, $this->pdoAttributes);
$statement = $pdo->prepare('insert into PHP_Project(upload) where ID = ? values (?,?)');

$statement->bindParam(1, $filename);
$statement->bindParam(2, $projectID);


I hope somebody can help me. Thanks in advance!!

Answer Source

The MYSQL query you wrote is incorrect. You need the MYSQL UPDATE query for updating the value at a specific column.

 $statement = $pdo->prepare('UPDATE PHP_Project SET upload = ? WHERE ID = ?');

Check out this tutorial Mysql update tutorial