Questions tagged [pg-query]

33 questions
0
votes
0 answers

pg_query_params is not substituting parameters in the query

I want my application to dynamically change which database and schema name it uses depending on whether it's running on a local machine, staging environment, or production. I thought pg_query_params would be a great choice because you can…
0
votes
1 answer

Node.js pg client query works for first query but fails for second query despite there being data

In the code below the first query works as expected and the result is fine. But when the second query runs the result is undefined and it throws an error when trying to access the row value. I have run the actual query manually in the db and it…
Kenobi
  • 465
  • 6
  • 13
0
votes
0 answers

pg_query Query failed: ERROR invalid input syntax for integer

Get the error message on submit. Warning: pg_query(): Query failed: ERROR: invalid input syntax for integer: "2018-03-11" LINE 1: INSERT INTO feedback2 VALUES ('2018-03-11', '1', '1','1','1'... ^ in /var/www/html/form/feedback.php on line…
0
votes
2 answers

Php postgresql variables in a query

I'm trying to get the right syntax for the following. In this case $post_pub = 1 $sql='SELECT "Publications"."Pub_ID", "Publications"."ART_TITEL" FROM "Publications" where "Pub_ID"="$post_pub"'; Php throws an error: column "$post_pub" does not…
Spatial Digger
  • 1,883
  • 1
  • 19
  • 37
0
votes
1 answer

pg_query throwing an error

I'm trying to get data from a postgresql database, I get the error: pg_last_error() expects parameter 1 to be resource, object given in /path/to/query.php So the data is as an object not a resource. Any ideas how to fix this? The SQL works with…
Spatial Digger
  • 1,883
  • 1
  • 19
  • 37
0
votes
1 answer

pg_query error going directly to console, while pg_last_error returns nothing

I'm updating some legacy PHP code and trying to get some decent error logging. All calls to the DB now go through this function: private function dbQuery($sql) { if (DEBUG) print("\n" . $sql . "\n"); $result = pg_query($this->dbh,…
Joe Strout
  • 2,634
  • 2
  • 28
  • 39
0
votes
0 answers

PHPExcel to insert database using Pg_query

I'm using PHP Excel to insert data CSV into database. But i confused to apply it. Here's Mycode:
Shieryn
  • 234
  • 2
  • 15
0
votes
0 answers

passing in DESC or ASC with pg_query_params in PHP and Postgres

$query = "SELECT field1, field2, field3, date_created, id FROM database WHERE field1 LIKE $1 OR field2 LIKE $1 ORDER BY date_created $2 LIMIT $3 OFFSET $4"; $result = pg_query_params($this->pgConnect($this->database_conn_string), $query,…
karl
  • 321
  • 3
  • 16
0
votes
0 answers

pg_connect relation doesn't exist although the table is in database and both are lowercase?

Here's the table definition in the database, I can insert rows no problem with PG Admin CREATE TABLE contact ( id serial NOT NULL, user_name character varying(50) NOT NULL DEFAULT ''::character varying, first_name character varying(50), …
Mideel
  • 17
  • 6
0
votes
1 answer

pg_query error because of name: 'kill 'em all'

pg_query can't be executed in the case where name = ' Kill 'em all ' the error is pointing at the " ' " before "em" which is the problem but i can't find a solution. $query = "INSERT INTO order (foodid,name) VALUES ($food_id,'$food')"; $result =…
prof chaos
  • 404
  • 3
  • 18
0
votes
1 answer

creating a table using $_POST parameters

I'm trying to create a table where the table name is a parameter. Is it possible? Like this: $result = pg_query("CREATE TABLE '$_POST[nome_arquivo_software]' ( id serial CONSTRAINT pk_'$_POST[nome_arquivo_software]' PRIMARY KEY, nome …
0
votes
1 answer

$_SESSION not working inside postgres query

after everything to fix it, I have no more ideas and came here to find some help. My $_SESSION isn't working inside an SELECT of postgres, but when I put like this it's OK: The genre you selected is: . But inside my…
0
votes
1 answer

How can PDO not return a row which pg_query() does?

I had a table with a bigserial PK, one character varying FK and a bigint FK and a unique constraint on these FKs, a character varying NOT NULL and two nullable smallints. All of this was running in a VM with Ubuntu 14.04.2 LTS, PHP 5.5.9 and…
Arc
  • 11,143
  • 4
  • 52
  • 75
-1
votes
1 answer

php postgresql concat hyperlink with fields

How to concat hyperlink in php postgresql query? I tried this but confused with single and double quotes. $query = "SELECT im.id AS \"ID\", im.type AS \"TYPE\", CONCAT('Click') FROM…
mysqlrockstar
  • 2,536
  • 1
  • 19
  • 36
-1
votes
1 answer

query failedERROR: prepared statement "my_query" does not exist

Hello All I'm trying to insert a form data into my postgreSQL DB in heroku through PHP and i tried all the solutions here but nothing solved my problem!. I can connect to the database but no operation worked well to me!. This error lead me to…
Ali Barani
  • 238
  • 2
  • 7
  • 17