Note that there are some explanatory texts on larger screens.

plurals
  1. POPostgreSQL doesn't insert values into table?
    text
    copied!<p>I'm working on a PHP code that runs a query on my PostgreSQL database:</p> <pre><code>$insert = pg_query($pg_conn, "INSERT INTO kullanicilar(id, u_name, u_firstname, u_lastname, register_date, gold, exp, play_times, level) VALUES($k_id, '$u_name', '$u_firstname', '$u_lastname', 'NOW()', 0, 0, 0, 1);" ); if ($insert) { echo 'Insert succeeded.'; } else { echo 'An error occurs when inserting'; } </code></pre> <p>I'm getting <strong>An error occurs when inserting</strong> message every time. What's wrong with my code?</p> <p><strong>-Edit- (Details)</strong></p> <p>I'm using Heroku Postgres. My variables' definitions are like this;</p> <pre><code>$k_id = intval($basic['id']); //int $u_name = $basic['name']; //string $u_firstname = $basic['first_name']; //string $u_lastname = $basic['last_name']; //string </code></pre> <p>Here is a part of my heroku log:</p> <pre><code>PHP Warning: pg_pconnect(): Unable to connect to Postg reSQL server: could not connect to server: Connection refused\n\tIs the server r unning on host "-----.amazonaws.com" and accepting\n\tTCP/ IP connections on port 5432? in /app/www/index.php on line 91, referer: http://a pps.facebook.com/---/ PHP Warning: pg_last_error() expects parameter 1 to be resource, boolean given in /app/www/index.php on line 119, referer: http://apps .facebook.com/---/ PHP Warning: pg_num_rows() expects parameter 1 to be r esource, null given in /app/www/index.php on line 106, referer: http://apps.face book.com/---/ PHP Warning: pg_query() expects parameter 1 to be reso urce, boolean given in /app/www/index.php on line 107, referer: http://apps.face book.com/---/ PHP Warning: pg_last_error(): No PostgreSQL link opene d yet in /app/www/index.php on line 111, referer: http://apps.facebook.com/---/ PHP Warning: pg_query() expects parameter 1 to be reso urce, boolean given in /app/www/index.php on line 98, referer: http://apps.faceb ook.com/---/ </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload