Robert Tossly
Robert Tossly

Reputation: 623

Data not being sent to database

I am making an image uploading feature which stores the file name in the database and the photo in a folder called uploaded. These photos are being moved to the uploaded folder but for some reason I cannot save the file name in the database.

My question is: Why isn't the file name passed through the database?

Upvotes: 2

Views: 81

Answers (1)

Robby Cornelissen
Robby Cornelissen

Reputation: 97130

That should be an update query instead of an insert query:

mysql_query("UPDATE users SET profile = '$file' WHERE id = '$var'");

Also note that:

  • You're using a deprecated API. Consider switching to the mysqli_* functions or using PDO.
  • You're wide open to SQL injection attacks. Consider using prepared statements.

Upvotes: 6

Related Questions