How can you solve the Resource ID #8 -error message in the following code?
The error apparently means that I have a bug in my SQL statement. However, I cannot see it.
$result = pg_prepare($dbconn, "query1", "SELECT user_id FROM users
WHERE email = $1;");
$result = pg_execute($dbconn, "query1", array("[email protected]"));
// to read the value
while ($row = pg_fetch_row($result)) {
$user_id = $row[0];
}
I get the error message when I try to echo $result
.
Don't
echo $result
-- it's a record set, not an actual value to beecho
ed. You should be able toecho $row[0]
within thewhile
loop, though:There's nothing wrong with the code that you posted, by the way--the syntax is fine.