Checking Insert to Postgre, whats wrong?
| From: | Bård Magnus Fauske | Date: | Sun, 28 Jul 2002 10:55:06 +0000 |
| Subject: | Checking Insert to Postgre, whats wrong? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-110046@lists.php.net to get a copy of this message | ||
Hello.
I use this code-snip similar to this to check if the inserted tuppel in my database was successfull:
--- snip ---
$OID = pg_last_oid($resultat);
if($OID<0) {
echo $errormessage;
exit;
}
$query = "SELECT * FROM medlemmer WHERE oid = '$OID';";
$resultat = pg_query($dbconnection, $query);
if (!$resultat) {
echo $errormessage;
exit;
} else {
$i = 0;
$medlem_id[$i] = pg_fetch_result($resultat, $i, "medlem_id");
$fornavn[$i] = pg_fetch_result($resultat, $i, "fornavn");
}
pg_free_result($resultat);
if (!$medlem_id[$i]) {
echo $errormessage;
exit;
} else {
$i = 0;
echo $medlem_id[$i].$fornavn[$i];
}
--- snip ---
But when I print the result from pg_fetch_result() to the browser (last lines above), I only get the first letter in the string $fornavn[$i] and similar strings not listed above, not the whole string. What is the reason for this? Has it something to do with the pg_last_oid()? I can't see how since this only identify the inserted row (or am I wrong?) which I select afterwards.
Thanks for answer.
Bård Magnus