Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
Unable to add values to postgreSQL

I'm working with php to add values read from a html web to a postgreSQL table, and I don't know why the value read doesn't add itself to the table. I'm working with pgAdminIV. Here is my code, hope someone could help me.

 <?php

  $mysqli=pg_connect("host=XXXXX.cim0cltex61z.us-west-2.rds.amazonaws.com port=5432 dbname=footplsseat user=footplsseat passsword=XXXXXXXX");
  $email= $_POST['email'];

  if (!$mysqli){
    echo "Connection failed";
  }
  else{
    echo "Succesfully connected";
  }

  $sql = "CREATE TABLE IF NOT EXISTS testportal (
  id INT, 
  email char(50)
 )";

 $query = "INSERT INTO testportal (email) VALUES ('$email')";

?>

EDIT: change id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, for id integer.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I solved my problem, I was mixing mySQL and postgresSQL code. Here is my solution:

<?php

$mysqli=pg_connect("host=XXXXX.cim0cltex61z.us-west-2.rds.amazonaws.com port=5432 dbname=footplsseat user=footplsseat password=XXXXXX");
$email = pg_escape_string($_POST['email']); 
$query = "INSERT INTO testportal(email) VALUES('" . $email . "')"; 
$result = pg_query($query); 
if (!$result) { 
    $errormessage = pg_last_error(); 
    echo "Error with query: " . $errormessage; 
    exit(); 
 } 
 printf ("These values were inserted into the database - %s", $email); 
 pg_close(); 

?> 
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!