I try to test a query from a PHP file without answer if there is an error.
For example, if I do that :
<?php
$dbconnect = pg_connect("host=localhost port=5432 dbname=" . $_POST['data1'] . " user=postgres password=jtgacdt");
$param = array ();
$result = pg_query($dbconnect,$_POST['data3']));
// $result = pg_query($dbconnect,'pg_query($dbconnect,' . $_POST['data3'] . ')';
if (!$result) {
$param ['titre'] = 'Oh no !';
$param ['message'] = 'Id doesn\'t work';
$param ['type'] = 'error';
echo json_encode ($param);
} else {
$param ['titre'] = 'Yes';
$param ['message'] = 'Cool';
$param ['type'] = 'Success';
};
pg_close($dbconnect);
?>
I don't have echo out of my condition code because I want to only return my parameters 'titre', 'message' and 'type', not that :
Warning: pg_query() [function.pg-query]: Query failed: ERROR (...)
But I've this error message AND my parameters...
I've a precision, I call this code with Ajax :
$.ajax({type: "POST", url: "script\\php\\postgres_php.php",data: {data1:db,data3:request}, async: false});
I tried function pg_query_params but it the same thing... It is possible to test the errors and control the echo of my PHP ?
display_errors, and error_reporting.