MichaelP
MichaelP

Reputation: 181

Postgres Query not executing

I'm trying to execute the following query;

 $result = pg_query($ruledbconnection, "INSERT INTO INPUT(target, prot, in, out, source, destination, id) VALUES ('$target', '$protocol', '$in', '$out', '$source', '$destination', '$id')");

This query should add different variables into a new row.

However, when I debug the statement (since it does not work) I get the following;

 ERROR: syntax error at or near "in" LINE 1: INSERT INTO INPUT(target, prot, in, out, source, destination... ^

I find this error vague and I'm not sure where to look. Any ideas?

Upvotes: 1

Views: 860

Answers (2)

slavoo
slavoo

Reputation: 6086

in is keyword.

Try this:

$result = pg_query($ruledbconnection, "INSERT INTO INPUT(target, prot, \"in\", out, source, destination, id) VALUES ('$target', '$protocol', '$in', '$out', '$source', '$destination', '$id')");

Upvotes: 1

Emma Paulowicz
Emma Paulowicz

Reputation: 356

Try this:

$result = pg_query($ruledbconnection, "INSERT INTO INPUT(target, prot, in, out, source, destination, id) VALUES ('".$target."', '".$protocol."', '".$in."', '".$out."', '".$source."', '".$destination."', '".$id."')");

Upvotes: 1

Related Questions