Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

The previous answers have been horribly complex for the scope of this project. I want to take the $_POST result as a variable and insert it into a BYTEA field of a table.

$_SESSION['username'] = $username;
$file = $_POST["file"];

file is the file itself submitted from the form on the previous page

pg_prepare($conn, "register_user_info", 'INSERT INTO fileDB.assignment(pawprint, name, number, section, file) VALUES ($1, $2, $3, $4, $5)'); 
pg_execute($conn, "register_user_info", array($username, "1", "1", "1", $file));

I need to insert the file itself into the file column of my database. How can I make this happen?

share|improve this question
1  
You're using PHP with PostgreSQL - you're not using psql, the command-line client for PostgreSQL. –  Craig Ringer Apr 15 '14 at 12:47

1 Answer 1

Your options are:

  • Use PDO, which properly supports binary parameters; or

  • Use pg_escape_bytea with string substitution into the query text.

See http://stackoverflow.com/q/17121791/398670 .

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.