Re: PHP-Postgres link

From: Serj MD <root(at)ocher(dot)pstu(dot)ac(dot)ru>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: PHP-Postgres link
Date: 2000-04-13 16:03:28
Message-ID: 00041312371801.11528@ocher
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
I don't use pg_fetch_array. My english very bad and reading englesh documents
veri dificult for me. I use pg_result() and it is working. Look this:
<script language="php">
// Connect to database, select from table, etc...
$conn = pg_connect();
$result = pg_exec();
$num = pg_NumRows($result);

//Output to html-page
for($i=0; $i<$num; $i++)
{
$userindex = pg_result($result, $i, "userindex");
$username = pg_result($result, $i, "username");
$password = pg_result($result, $i, "password"); // not good idea to my mind
$field_4 = pg_result($result, $i, "field _4");
echo "userindex: <i>$userindex</i>, username <i>$username</i>, password:<i>$password</i><br>";
}
</script>

It's worked. I don't have problem.

Best regards,
Serj MD

> Hi,
> I didn't get what is the exact problem/error about the part of the php code.
> May be you should explain more....
> Any way, I had offen used pg_fetch_array function to get the data from the
> tables. But If there is a sintax problem/error on your code,As I noticed,
> may be you have to simply correct it by putting a ";" at the end of echo
> instead of "." like this :
>
> echo pg_result($result, $i, "userindex") . " | " . pg_result($result, $i,
> "username") . " | " . pg_result($result, $i, "password") . " | "
> .pg_result($result, $i, "field 4???") . " <BR> " ;
>
>
> Hope that helps. Feel free to contact me .
> Omid Omoomi
>
>
>
> >From: Serj MD <root(at)ocher(dot)pstu(dot)ac(dot)ru>
> >To: pgsql-general(at)postgresql(dot)org
> >Subject: Re: [GENERAL] PHP-Postgres link
> >Date: Wed, 12 Apr 2000 07:31:21 -0400
> >
> >Hello,
> >I don't speak english, I'm sorry
> >My example:
> >
> >$connection = pg_connect("", "", "", "users");
> >$query = pg_exec($connection, "INSERT INTO login VALUES ( '$userindex',
> >'$uname', '$password', '1')");
> >$result = pg_exec ($connection, "select * from login");
> >$num = pgNumRows($result);
> >for($i = 0; $i < $num; $i++)
> >{
> >echo pg_result($result, $i, "userindex") . " | " . pg_result($result, $i,
> >"username") . " | " . pg_result($result, $i, "password") . " | "
> >.pg_result($result, $i, "field 4???") . " <BR> " .
> >}
> >
> >
> >???????????????????????????????
> >
> >Best regards,
> >Serj MD

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2000-04-13 16:22:58 Re: Changes from 6.5 to 7.0?
Previous Message Farren Isaacs 2000-04-13 15:59:07 Oid data type question