Call to undefined function pg_query in php

ON “centOS”

<?php
$db = pg_connect("host=localhost port=5432 dbname=postgres user=postgres password=admin123");
if($db){
    echo "connected!";
    $query = "INSERT INTO book VALUES (3,'bookName','authorName',344)";
    $result = pg_query($query);
    if($result){
            echo "inserted";
    }else{
            echo "error inserting";
    } 
}else{
    echo "error connecting";
?>

Expected output:conneted!
inserted OR error inserting

Actual output:**connected!

Fatal error: Uncaught Error: Call to undefined function pg_query() in /opt/lampp/htdocs/newplsql/connect.php:24 Stack trace: #0 {main} thrown in /opt/lampp/htdocs/newplsql/connect.php on line 24**