Re: unable to insert rows with php

From: "Duncan Adams (DNS)" <duncan(dot)adams(at)vcontractor(dot)co(dot)za>
To: pgsql-php(at)postgresql(dot)org
Subject: Re: unable to insert rows with php
Date: 2002-05-20 13:18:49
Message-ID: 7DD34E6DF5CD1B4283DDAB96A855DCED2F334F@vodabemail1.vodacom.co.za
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php


$query3 = "INSERT INTO friends (id, firstname,
surname) values (nextval('friends_id_seq'),
'$firstname', '$surname')";

where do u get the values for $firstname and $surname
should that not be $row[1]
and row[2]

-----Original Message-----
From: ktt [mailto:kestutis98(at)yahoo(dot)com]
Sent: Monday, May 20, 2002 2:04 PM
To: angelo(dot)rigo(at)globo(dot)com
Cc: pgsql-php(at)postgresql(dot)org
Subject: Re: [PHP] unable to insert rows with php

--- angelo(dot)rigo(at)globo(dot)com wrote:
> Can you show your code ?

yes. it's written for test.
------

<html><body>
<?php
$db = pg_connect("dbname=friends user=kes");
$query1 = "SELECT * FROM friends";
$result = pg_exec($db,$query1);
if (!$result) {printf ("ERROR");
exit;
}
$row = pg_fetch_row ($result,0);
printf ("ID : %s<br>\n", $row[0]);
printf ("First Name: %s<br>\n", $row[1]);
printf ("Surname : %s<br>\n", $row[2]);
$query3 = "INSERT INTO friends (id, firstname,
surname) values (nextval('friends_id_seq'),
'$firstname', '$surname')";
$result = pg_exec($db, $query3);
if (!$result) { printf ("ERROR");
$errormessage = pg_errormessage($db);
echo $errormessage;
exit;
}
pg_close();
printf ("These values were inserted into the database
- %s %s", $firstname, $surname);

echo"<form action=\"pgsqltest0.php\"
method=\"post\">";
echo "First Name : <input type=\"text\"
name=\"firstname\" size=\"40\" length=\"40\"
value=\"FirstName\">";
echo "<BR> Surname : <input type=\"text\"
name=\"surname\" size=\"40\" length=\"40\"
value=\"Surname\">";
echo "<BR><input type=\"submit\" name=\"submit\"
value=\"Submit\">";
echo " <input type=\"reset\" name=\"reset\"
value=\"Clear It\"></form> </body> </html>";

?>

> -- Mensagem Original --
>
> >
> >Hello,
> >
> >I'm trying to insert data in the table, using PHP
> >interface, but script creates an empty
> >row without data.
> >If you had similar problem, please, suggest
> >a solution.
> >I'm using Debian potato, PostgreSQL 7.2,
> >Apache 1.3.24.
> >
> >Thank you in advance,
> >
> >ktt
> >
> >
> >
> >
> >__________________________________________________
> >Do You Yahoo!?
> >LAUNCH - Your Yahoo! Music Experience
> >http://launch.yahoo.com
> >
> >---------------------------(end of
> broadcast)---------------------------
> >TIP 2: you can get off all lists at once with the
> unregister command
> > (send "unregister YourEmailAddressHere" to
> majordomo(at)postgresql(dot)org)
> >
>
>
>
>
> ________________________________________
> A busca mais veloz e precisa da internet. Acesse
> agora: http://www.zoom.com.br.
>

__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org

Responses

Browse pgsql-php by date

  From Date Subject
Next Message mike 2002-05-20 13:31:22 Re: unable to insert rows with php
Previous Message ktt 2002-05-20 12:04:18 Re: unable to insert rows with php