3
Imagine the following consultation:
pg_query($conn,"selects * from tabela");
Considering there’s a mistake in selects
,
'ERROR: syntax error at or near "selects" LINE 1: selects * from table... ^'
How can I get this result and move to a php variable?
I tested it in the following ways, but without success:
1
$sql = 'selects * from table'
if(pg_query($conn,$sql)) $res = 'ok'; else $res = pg_last_error($conn);
2
$sql = pg_query($conn,"selects * from table");
if($sql) $res = 'ok'; else $res = pg_result_status($sql);
3
$sql = pg_query($conn,"selects * from table");
if(pg_affected_rows($sql)>0) $res = 'ok'; else $res = pg_result_status($sql);
4
$sql = pg_query($conn,"selects * from table");
if(pg_affected_rows($sql)>0) $res = 'ok'; else $res = pg_last_result($conn);
I do not understand very well what you want, want to store in a variable the error message?
– RXSD
@Andréfilipe, that’s right.
– Groot
Just a curiosity: Why are you trying to force this error, why not execute the comment correctly?
– RXSD
@Andréfilipe, I’m not forcing, sometimes you have a clerical error typing the code and I want to record that information, that’s all
– Groot
It is SELECT and not SELECTS. Take this s from the end.
– anonimo
@anonymity, did not read the question carefully...
– Groot