JotaTR Posted September 18, 2013 Share Posted September 18, 2013 Hi there. I am new at php and postegresql, I have installed postegreSQL 9.3 and wampserver 2.3. I have already enable the postgreSQL extensions. I am trying to acess a database with the name db where is already created a 3 collumn table (text,text,double). I want to insert a value into it using a php code. The php code that i have is this: $dbconn = pg_connect("host=localhost port=5432 dbname=postgres user=postgres password=passss") or die('It was not possible to connect: ' . pg_last_error()); echo 'Connected: ', pg_dbname($dbconn); $query = "INSERT INTO bd( dia, hora, voltagem) VALUES ('18-9-2013', '17:32:37', 302);"; $linha=pg_query($dbconn,$query); pg_close($dbconn); When opening the file in the browser i get: Connected: postgres ( ! ) Warning: pg_query(): Query failed: ERROR: relation "bd" does not exist LINE 1: INSERT INTO bd( ^ in C:\wamp\www\connectDB.php on line 12 Call Stack # Time Memory Function Location 1 0.0005 246472 {main}( ) ..\connectDB.php:0 2 0.0354 247848 pg_query ( ) ..\connectDB.php:12 What am i doing wrong? i dont get it. Does anyone can give me a little help? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/282252-error-inserting-values-into-a-row-in-postgresql-throught-php/ Share on other sites More sharing options...
jebriggsy Posted September 17, 2014 Share Posted September 17, 2014 Just a guess as I'm new to PostgreSQL myself, but you might need a space inbetween the table name and the opening parenthesis. I'm thinking that because there is a new line after the opening parenthesis without a space between it and the table name PostgreSQL is assuming the table name is "bd(" and not "bd". At least that's the impression I got after reading http://www.postgresql.org/docs/9.3/static/sql-syntax-lexical.html Link to comment https://forums.phpfreaks.com/topic/282252-error-inserting-values-into-a-row-in-postgresql-throught-php/#findComment-1491373 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.