pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
unable to insert rows with php
5+ messages / 4 participants
[nested] [flat]

* unable to insert rows with php
@ 2002-05-20 11:20  ktt <kestutis98@yahoo.com>
  0 siblings, 0 replies; 5+ messages in thread

From: ktt @ 2002-05-20 11:20 UTC (permalink / raw)
  To: pgsql-php


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



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: unable to insert rows with php
@ 2002-05-20 12:04  ktt <kestutis98@yahoo.com>
  0 siblings, 1 reply; 5+ messages in thread

From: ktt @ 2002-05-20 12:04 UTC (permalink / raw)
  To: angelo.rigo@globo.com; +Cc: pgsql-php

--- angelo.rigo@globo.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@postgresql.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



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: unable to insert rows with php
@ 2002-05-20 13:18  Duncan Adams (DNS) <duncan.adams@vcontractor.co.za>
  0 siblings, 1 reply; 5+ messages in thread

From: Duncan Adams (DNS) @ 2002-05-20 13:18 UTC (permalink / raw)
  To: 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@yahoo.com]
Sent: Monday, May 20, 2002 2:04 PM
To: angelo.rigo@globo.com
Cc: pgsql-php@postgresql.org
Subject: Re: [PHP] unable to insert rows with php


--- angelo.rigo@globo.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@postgresql.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@postgresql.org



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: unable to insert rows with php
@ 2002-05-20 13:31  mike <mike@partner2partner.com>
  parent: ktt <kestutis98@yahoo.com>
  0 siblings, 0 replies; 5+ messages in thread

From: mike @ 2002-05-20 13:31 UTC (permalink / raw)
  To: pgsql-php

ktt writes:
> 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')";

You are not copying the values into the fields you are using in the INSERT 
statement: 

$firstname = $row[1];
$surname = $row[2]; 

Or 

$query3 = "INSERT INTO friends (id, firstname, surname) values 
(nextval('friends_id_seq'), '" . $row[1] . "', '" . $row[2] . "')"; 

Michael J. Upchurch
Partner2Partner Communications  mike@partner2partner.com  615.286.2199 




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: unable to insert rows with php
@ 2002-05-20 16:27  Keary Suska <hierophant@pcisys.net>
  parent: Duncan Adams (DNS) <duncan.adams@vcontractor.co.za>
  0 siblings, 0 replies; 5+ messages in thread

From: Keary Suska @ 2002-05-20 16:27 UTC (permalink / raw)
  To: pgsql-php

on 5/20/02 7:18 AM, duncan.adams@vcontractor.co.za purportedly said:

> 
> $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]

Actually, this code has a submit form, which is where I would assume the
variable values come from. Make sure that register_gloabls is on. Add
phpinfo() to the end of the script to check the current value of
register_globals. If it is off, which is preferable, then you need to use
$_POST (PHP v4.1+) or $HTTP_POST_VARS. As of 4.2.0, register_globals if OFF
by default.

> 
> -----Original Message-----
> From: ktt [mailto:kestutis98@yahoo.com]
> Sent: Monday, May 20, 2002 2:04 PM
> To: angelo.rigo@globo.com
> Cc: pgsql-php@postgresql.org
> Subject: Re: [PHP] unable to insert rows with php
> 
> 
> --- angelo.rigo@globo.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@postgresql.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@postgresql.org
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/users-lounge/docs/faq.html
> 


Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"




^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2002-05-20 16:27 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-05-20 11:20 unable to insert rows with php ktt <kestutis98@yahoo.com>
2002-05-20 12:04 Re: unable to insert rows with php ktt <kestutis98@yahoo.com>
2002-05-20 13:31 ` mike <mike@partner2partner.com>
2002-05-20 13:18 Re: unable to insert rows with php Duncan Adams (DNS) <duncan.adams@vcontractor.co.za>
2002-05-20 16:27 ` Keary Suska <hierophant@pcisys.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox