This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to insert data in Postgresql using PHP

I would like to add rows to my table in PostGresql. I wrote the following code:

$M = array("H","HS","P");
$dbconn = pg_Connect(pg_Connect("localhost", "5432", "", "", "test");
foreach ($M as $Match){
       $query = "INSERT INTO table_name ("ID","SP","Match") VALUES ("A","Human",$Match);
       $query = pg_query($query);
}
pg_Close($dbconn);

I got as error "query fails". Could someone tell me what I am doing wrong?

php postgresql html query postgresql

You should consult the php pg and postgres documentation, and possibly ask on Stackoverflow. There is no relation to bioinformatics other than the implied application to "Human", therefore the question will be closed soon.

Hint: your string syntax is wrong , you need to check the quotation and learn the basics of php strings.

Hello nemo!

Tangentially realted to bioinformatics. @Michael has provided useful hint to fix.

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

0 answers

No answers yet.

Log in to answer this question.