0

Using PHP, the following string was generated

INSERT INTO persons ("username","firstname") VALUES ('nino','Niño')

but when tried to execute the statement at runtime like so:

<?php
...
$query = 'INSERT INTO persons ("username","firstname")'." VALUES ('nino','Niño')";
$result = $pgsql->query( $query );
?>

it was not inserted to the table, but when I issued the same statement in the phpPgAdmin, it was inserted.

Is there a working way to insert accented characters in PostreSQL using PHP & ezSQL?

Abel Callejo
  • 13,779
  • 10
  • 69
  • 84

1 Answers1

1

Try this.

$data = 'Niño'
$escaped = pg_escape_string(utf8_encode($data));
$query  = "INSERT INTO correspondence (name, data) VALUES ('nino', '{$escaped}')"
Tony Vincent
  • 13,354
  • 7
  • 49
  • 68