Re: PHP-Postgres link - Mailing list pgsql-general

From Serj MD
Subject Re: PHP-Postgres link
Date
Msg-id 00041312371801.11528@ocher
Whole thread Raw
In response to Re: PHP-Postgres link  ("omid omoomi" <oomoomi@hotmail.com>)
List 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@ocher.pstu.ac.ru>
> >To: pgsql-general@postgresql.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

pgsql-general by date:

Previous
From: Michael Sobolev
Date:
Subject: Re: Character encodings...
Next
From: "Oliver Elphick"
Date:
Subject: Re: Character encodings...